UVaOJ 401 - Palindromes

#include<iostream>
#include<cstring>
using namespace std;


int is_Palindrome(char *A)
{
    int len = strlen(A);
    for(int i = 0; i < len; i++)
        if(A[i] != A[len-1-i])  return 0;
    return 1;
}


int is_Mirroied(char *A)
{
    int len = strlen(A);
    char B[25];
    for(int i = 0; i < len; i++)
    {
        if(A[i]!='E' && A[i]!='3' && A[i]!='J' && A[i]!='L' && A[i]!='S' && A[i]!='2' && A[i]!='Z' && A[i]!='5' && A[i]!='A'&& A[i]!='H' && A[i]!='I' && A[i]!='M' && A[i]!='O' && A[i]!='T' && A[i]!='U' && A[i]!='V' &&A[i]!='W' && A[i]!='X' && A[i]!='Y' && A[i]!='1' && A[i]!='8')
             return 0;
        else
        {


            if(A[i]=='E')  B[i] = '3';
            else if(A[i]=='J')  B[i] = 'L';
            else if(A[i]=='L')  B[i] = 'J';
            else if(A[i]=='S')  B[i] = '2';
            else if(A[i]=='Z')  B[i] = '5';
            else if(A[i]=='2')  B[i] = 'S';
            else if(A[i]=='3')  B[i] = 'E';
            else if(A[i]=='5')  B[i] = 'Z';
            else if(A[i]=='A')  B[i] = 'A';
            else if(A[i]=='H')  B[i] = 'H';
            else if(A[i]=='I')  B[i] = 'I';
            else if(A[i]=='M')  B[i] = 'M';
            else if(A[i]=='O')  B[i] = 'O';
            else if(A[i]=='T')  B[i] = 'T';
            else if(A[i]=='U')  B[i] = 'U';
            else if(A[i]=='V')  B[i] = 'V';
            else if(A[i]=='W')  B[i] = 'W';
            else if(A[i]=='X')  B[i] = 'X';
            else if(A[i]=='Y')  B[i] = 'Y';
            else if(A[i]=='1')  B[i] = '1';
            else if(A[i]=='8')  B[i] = '8';


        }
    }
    for(int i = 0; i < len; i++)
        if(A[i] != B[len-1-i]) return 0;
    return 1;


}






int main()
{
    char A[25];
    while(cin>>A)
    {
       if(is_Palindrome(A)==0&&is_Mirroied(A)==0)
       {
           cout<<A<<" -- is not a palindrome."<<endl;
           cout<<endl;
       }
       if(is_Palindrome(A)==1&&is_Mirroied(A)==0)
       {
           cout<<A<<" -- is a regular palindrome."<<endl;
           cout<<endl;
       }
       if(is_Palindrome(A)==0&&is_Mirroied(A)==1)
       {
           cout<<A<<" -- is a mirrored string."<<endl;
           cout<<endl;
       }
       if(is_Palindrome(A)==1&&is_Mirroied(A)==1)
       {
           cout<<A<<" -- is a mirrored palindrome."<<endl;
           cout<<endl;
       }
    }


    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值