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 ||:::
7 Respostas
+ 2
thank you so much. I'll try it out now amd give you the feedback
+ 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;
}
+ 1
Alright. Yes, it's fine to use strings.
+ 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;
}
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.
0
Ill just post a similar solution, with switch and modulo. But is it fine to use strings?
0
It worked. thanks so much