Im trying to solve ACM - 10082
Judge is responding wrong answer...but, i have no idea why.
Any suggestion?
#include<iostream>
#include<string>
using namespace std;
char change(char x);
int main()
{
string str1;
getline(cin, str1, '\n');
transform(str1.begin(), str1.end(), str1.begin(), change);
cout << str1;
return 0;
}
char change(char x)
{
//---first row----------
if(x == '1') return 96;
if(x == '2') return '1';
if(x == '3') return '2';
if(x == '4') return '3';
if(x == '5') return '4';
if(x == '6') return '5';
if(x == '7') return '6';
if(x == '8') return '7';
if(x == '9') return '8';
if(x == '0') return '9';
if(x == '-') return '0';
if(x == '=') return '-';
//----2nd row------------
if(x == 'Q') return 9;
if(x == 'W') return 'Q';
if(x == 'E') return 'W';
if(x == 'R') return 'E';
if(x == 'T') return 'R';
if(x == 'Y') return 'T';
if(x == 'U') return 'Y';
if(x == 'I') return 'U';
if(x == 'O') return 'I';
if(x == 'P') return 'O';
if(x== '[') return 'P';
if(x== ']') return '[';
if(x== '\\') return ']';
//----3rd row------------
if(x== 'S') return 'A';
if(x== 'D') return 'S';
if(x== 'F') return 'D';
if(x== 'G') return 'F';
if(x== 'H') return 'G';
if(x== 'J') return 'H';
if(x== 'K') return 'J';
if(x== 'L') return 'K';
if(x== '\;') return 'L';
if(x== '\'') return '\;';
//---4th row-------------
if(x== 'X') return 'Z';
if(x== 'C') return 'X';
if(x== 'V') return 'C';
if(x== 'B') return 'V';
if(x== 'N') return 'B';
if(x== 'M') return 'N';
if(x== ',') return 'M';
if(x== '.') return ',';
if(x== '/') return '.';
if(x == ' ') return ' ';
}
one more thing, is there any way to get ride of this if-return part with something else.