+ 1
You can just do something like cin >> ch; ch = toupper(ch);//#<cctype> cout <<(char) ('Z'-(ch-'A'))<< endl;
17th May 2022, 6:22 AM
Raul Ramirez
Raul Ramirez - avatar
+ 2
Wdym by its corresponding one ? You state having one backward so like {A,B,C } {C,B,A } ??
17th May 2022, 6:09 AM
Raul Ramirez
Raul Ramirez - avatar
+ 1
Whats an example of input and out you expecting ?
17th May 2022, 6:14 AM
Raul Ramirez
Raul Ramirez - avatar
+ 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
17th May 2022, 6:52 AM
Raul Ramirez
Raul Ramirez - avatar
+ 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
17th May 2022, 10:03 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
char self = 'A'; char complement = 'Z'-self%'A'; cout<< complement << endl;
22nd May 2022, 12:02 PM
Vinit Sonawane
Vinit Sonawane - avatar