0

How do I convert a 5 digit zipcode to POSTNET code below . (In the description )

Use the table below to encode each of the digits in your "pseudo" barcode from Part 1.  Note: do not put spaces between the encoded digits.   Value Encoding 1 :::|| 2 ::|:| 3 ::||: 4 :|::| 5 :|:|: 6 :||:: 7 |:::| 8 |::|: 9 |:|:: 0 ||:::

22nd Feb 2018, 2:31 PM
Timew2
Timew2 - avatar
7 Respuestas
+ 2
thank you so much. I'll try it out now amd give you the feedback
22nd Feb 2018, 6:58 PM
Timew2
Timew2 - avatar
+ 1
Here. Try doing it yourself next time. #include<iostream> #include<string> #include<array> using namespace std; int main() { string sin, sout; cin>>sin; array<string,10> pnet = { "||:::", ":::||", "::|:|", "::||:", ":|::|", ":|:|:", ":||::", "|:::|", "|::|:", "|:|::" }; for(char c:sin) if(c>='0'&&c<='9') sout+=pnet.at(c-'0'); cout<<sout<<endl; }
22nd Feb 2018, 4:32 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
Alright. Yes, it's fine to use strings.
22nd Feb 2018, 5:52 PM
Timew2
Timew2 - avatar
+ 1
Here. No Arrays. #include<iostream> #include<string> using namespace std; int main() { int code; string sout; cin>>code; while(code!=0) { switch(code%10) { case 0: sout="||:::"+sout; break; case 1: sout=":::||"+sout; break; case 2: sout="::|:|"+sout; break; case 3: sout="::||:"+sout; break; case 4: sout=":|::|"+sout; break; case 5: sout=":|:|:"+sout; break; case 6: sout=":||::"+sout; break; case 7: sout="|:::|"+sout; break; case 8: sout="|::|:"+sout; break; case 9: sout="|:|::"+sout; break; } code/=10; } cout<<sout<<endl; }
22nd Feb 2018, 6:22 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
0
wow , thanks so much. but I'm trying to use the modulous % and if else statements. It's for a school project and we haven't gotten to arrays yet. so I can't use it.
22nd Feb 2018, 5:50 PM
Timew2
Timew2 - avatar
0
Ill just post a similar solution, with switch and modulo. But is it fine to use strings?
22nd Feb 2018, 5:51 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
0
It worked. thanks so much
28th Feb 2018, 2:07 AM
Timew2
Timew2 - avatar