TOPIC

WHY 30% WRONG ?

Arif khan asked 3 years ago

include<bits/stdc++.h>

using namespace std;

char check(char ch) { if(ch == 'A' or ch == 'B' or ch == 'C') return '2'; else if(ch == 'D' or ch == 'E' or ch == 'F') return '3'; else if(ch == 'G' or ch == 'H' or ch == 'I') return '4'; else if(ch == 'J' or ch == 'K' or ch == 'L') return '5'; else if(ch == 'M' or ch == 'N' or ch == 'O') return '6'; else if(ch == 'P' or ch == 'Q' or ch == 'R' or ch == 'S') return '7'; else if(ch == 'T' or ch == 'U' or ch == 'V') return '8'; else if(ch == 'W' or ch == 'X' or ch == 'Y' or ch == 'Z') return '9';

} int main() {

int n;
string s;
while(getline(cin,s)){
        string part1;
    for(int i = 0, sx = s.size(); i < sx ; i++){
        if(isdigit(s[i])) part1 += s[i];
            else if(s[i] >= 'A' and s[i] <= 'Z') part1 += check(s[i]);
              else if(s[i] == '*' or s[i] == '#') part1 += s[i];
      }
    cout << part1 << endl;
}

return 0;

}

Remember not post solutions. Your post may be reviewed by our moderators.

  • Wyllian Brito replied 3 years ago

    It's not written on the statement, but try to convert the input to uppercase.