+ 1
You can just do something like
cin >> ch;
ch = toupper(ch);//#<cctype>
cout <<(char) ('Z'-(ch-'A'))<< endl;
+ 2
Wdym by its corresponding one ?
You state having one backward so like
{A,B,C }
{C,B,A }
??
+ 1
Whats an example of input and out you expecting ?
+ 1
All chars have an associated decimal number (ascii table )
(ch -âAâ) -> ch - 65
Basically how far from 65 am I => disp
(âZâ- disp ) -> 90 - disp
From 90 take away the disp
(char) cast back to a character
+ 1
Manav Roy
You could create 1 alphabet consisting of 26 letters with string indexes ranging from 0 to 25
IE: A = 0, Z = 25
In order to get the reverse letter, you can use
25 - index of letter
IE:
A = 0. 25 - 0 = 25 = Z
D = 3. 25 - 3 = 22 = V
Y = 24. 25 - 24 = 1 = B
Of course, you could use different alphabets
+ 1
char self = 'A';
char complement = 'Z'-self%'A';
cout<< complement << endl;