B. 完美对称

来源:互联网 发布:拼音域名 编辑:程序博客网 时间:2024/05/21 19:55

B. 完美对称

我们把一个完全对称的字符串称为“完美对称”的字符串,请仔细观察字母表,判断给出的字符串是否“完美对称”。

Input
案例有多组,每组给出一个只由大小写字母组成的字符串,长度不大于1000。

Output
每行输出一个答案,如果给出的字符串位“完美对称”,输出“Yes”,否则,输出“No”。

Sample Input
AoA
aoa
Sample Output
Yes
No

#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<algorithm>#include<stack>#include<queue>#include<cctype>#include<functional>using namespace std;#define swap(a,b) {long long c=a;a=b;b=c;}const int MAX = 999999;const double Eps = 1e-12;const double PI = acos(-1.0);int gcd(int x, int y){    return x%y == 0 ? y : gcd(y, x%y);}int main(){    int i, len, count;    char a[2000], b[2000], c[2000];    memset(a, '\0', sizeof(a));    while (cin >> a)    {        count = 0;        memset(b, '\0', sizeof(b));        memset(c, '\0', sizeof(c));        len = strlen(a);        for (i = 0; i<len; i++)        {            if (a[i] == 'A')                c[i] = 'A';            if (a[i] == 'b')                c[i] = 'd';            if (a[i] == 'd')                c[i] = 'b';            if (a[i] == 'H')                c[i] = 'H';            if (a[i] == 'I')                c[i] = 'I';            if (a[i] == 'M')                c[i] = 'M';            if (a[i] == 'O')                c[i] = 'O';            if (a[i] == 'o')                c[i] = 'o';            if (a[i] == 'p')                c[i] = 'q';            if (a[i] == 'q')                c[i] = 'p';            if (a[i] == 'T')                c[i] = 'T';            if (a[i] == 'U')                c[i] = 'U';            if (a[i] == 'V')                c[i] = 'V';            if (a[i] == 'v')                c[i] = 'v';            if (a[i] == 'W')                c[i] = 'W';            if (a[i] == 'w')                c[i] = 'w';            if (a[i] == 'X')                c[i] = 'X';            if (a[i] == 'x')                c[i] = 'x';            if (a[i] == 'Y')                c[i] = 'Y';        }        for (i = 0; i < len; i++)            b[i] = a[len - 1 - i];        if (!strcmp(b, c))            cout << "Yes" << endl;        else            cout << "No" << endl;    }    return 0;}
原创粉丝点击