UVa-401 Palindromes

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    string a;
    while(cin>>a)
    {
        int k=a.size();
        bool f1=1,f2=1;
        for(int i=0;i<k&&f1;i++)
            if(a[i]!=a[k-1-i])
                f1=0;
        char c1[]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"};
        char c2[]={"A000300HIL0JM0O0002TUVWXY51SE0Z0080"};
        int k1=strlen(c1);
        for(int i=0;i<k&&f2;i++)
            for(int j=0;j<k1&&f2;j++)
                if(a[i]==c1[j])
                    if(a[k-1-i]!=c2[j])
                        f2=0;
        if(f1&&f2)
            cout<<a<<" -- is a mirrored palindrome.";
        else if(f1&&!f2)
            cout<<a<<" -- is a regular palindrome.";
        else if(!f1&&f2)
            cout<<a<<" -- is a mirrored string.";
        else if(!f1&&!f2)
            cout<<a<<" -- is not a palindrome.";
        cout<<endl<<endl;
    }
}

posted on 2015-02-14 03:12  windrises  阅读(124)  评论(0编辑  收藏  举报

导航