UVA 401-Palindromes

来源:互联网 发布:linux开机自启动 编辑:程序博客网 时间:2024/05/16 10:02

水题细节也很重要啊。。。

In addition, after each output line, you must print an empty line.

#include<iostream>#include<cstdio>#include<cmath>#include<cstring>typedef long long ll;using namespace std;char const *ch = "AEHIJLMOSTUVWXYZ12358";char const *re = "A3HILJMO2TUVWXY51SEZ8";bool ispalindrome(string s){   int len=s.size();    for(int i=0;i<len/2;i++)    if(s[i]!=s[len-i-1]) return false;    return true;}bool ismirror(string s){   int len=s.size();    int table_len = strlen(ch);    int i,j;    if(len == 1)    {        for( j=0; j<table_len; j++)        {            if(ch[j] == s[0])                break;        }        if(j == 21 || re[j] != s[0])            return 0;    }    else        {    for(i=0; i<len/2; i++)            {            for(j=0; j<table_len; j++)            {            if(ch[j] == s[i])                break;            }            if(j == 21 || re[j] != s[len-i-1])            return 0;        }    return 1;        }}using namespace std;int main(){   string s;    while(cin>>s)    {        if(ispalindrome(s))            {if(ismirror(s)) {cout<<s<<" -- is a mirrored palindrome.\n"<<endl;continue;}             else   {cout<<s<<" -- is a regular palindrome.\n"<<endl;continue;}}       else {            if(ismirror(s)) {cout<<s<<" -- is a mirrored string.\n"<<endl;continue;}            else {cout<<s<<" -- is not a palindrome.\n"<<endl;continue;}            }    }    return 0;}


0 0