招行信用卡开发岗笔试题第一题
#include<iostream> #include<vector> #include<map> using namespace std; int main() { int N; cin >> N; vector<string> v; map<int, int> m; m[1] = 1; m[2] = 5; m[5] = 2; m[3] = 8; m[8] = 3; m[4] = 7; m[7] = 4; m[6] = 9; m[9] = 6; while (N--) { string s; cin >> s; v.push_back(s); } for (int j = 0; j < v.size(); j++) { string str = v[j]; int tmp = 1; for (int i = 0; i < str.size()&&tmp==1; i++) { int a = str[i] - '1'+1; int b = str[str.size() - i - 1] - '1'+1; if (a != m[b]) { cout << "NO" << endl; tmp = 0; break; } } if (tmp == 1) cout << "YES"<<endl; } return 0; }