1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
string number;
char number1[8];
int counter;
char a='A',b='B',c='C',d='D',e='E',f='F',g='G',h='H',i='I',j='J',k='K',l='L';
char m='M',n='N',o='O',p='P',r='R',s='S',t='T',u='U',v='V',w='W',x='X',y='Y';
char hyphen='-';
cout<<"Enter your phone-number: " <<endl;
getline(cin,number);
size_t findhyphen=number.find(hyphen);
for(counter=0;counter<8;counter++)
{
number1[counter]=number[counter];
}
for(counter=0;counter<8;counter++)
{
if(number1[counter]=='1')
{
cout<<1;
}
if(number1[counter]=='0')
{
cout<<0;
}
if(number1[counter]==hyphen)
{
cout<<hyphen;
}
if((number1[counter]==a)||(number1[counter]==b)||(number1[counter])==c||(number1[counter]=='2'))
{
cout<<2;
}
if((number1[counter]==d)||(number1[counter]==e)||(number1[counter]==f)||(number1[counter]=='3'))
{
cout<<3;
}
if((number1[counter]==g)||(number1[counter]==h)||(number1[counter]==i)||(number1[counter]=='4'))
{
cout<<4;
}
if((number1[counter]==j)||(number1[counter]==k)||(number1[counter]==l)||(number1[counter]=='5'))
{
cout<<5;
}
if((number1[counter]==m)||(number1[counter]==n)||(number1[counter]==o)||(number1[counter]=='6'))
{
cout<<6;
}
if((number1[counter]==p)||(number1[counter]==r)||(number1[counter]==s)||(number1[counter]=='7'))
{
cout<<7;
}
if((number1[counter]==t)||(number1[counter]==u)||(number1[counter]==v)||(number1[counter]=='8'))
{
cout<<8;
}
if((number1[counter]==w)||(number1[counter]==x)||(number1[counter]==y)||(number1[counter]=='9'))
{
cout<<9;
}
if(findhyphen!=3)
{
swap(number1[3],number1[4]);
}
|