uva401_水题(映射)


///
作者:tt2767
声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0
查看本文更新与讨论请点击:http://blog.csdn.net/tt2767
链接被删请百度: CSDN tt2767
///


原来一直都是一个一个switch来着,这回方便了。。。


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//
#include<iostream>
#include<algorithm>
#include<string>
#include <iterator>
#include<sstream>
#include<functional>
#include<numeric>
///
#include<vector>
#include<map>
#include <stack>
#include<queue>
#include<set>
#include <bitset>
#include <list>
using namespace std;
#define lch(x)  ((x) << 1)
#define rch(x) ((x)<<1|1)
#define dad(x) ((x)>>1)
#define lowbit(x) ((x)&(-x))
typedef  long long int LL;
const int INF = ~0U>>1;
const double eps = 1e-6;
const long double PI = acos(0.0) * 2.0;
const int N = 10 + 30000;
char a[N];
char s[N]="ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
char h[N]="A   3  HIL JM O   2TUVWXY51SE Z  8 ";
char mp[N]={0};
bool p(char * x);
bool m(char * x);
int main()
{
    //ios::sync_with_stdio(false);
#ifdef ONLINE_JUDGE
#else
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    for(int  i = 0 ; i< 35 ; i++)    mp[ s[i] ] = h[i];

    while(gets(a))
    {
        printf("%s",a);
        bool x = p(a),y = m(a);

        if(x && y)  puts(" -- is a mirrored palindrome.");
        else if(!x && !y)   puts(" -- is not a palindrome.");
        else if(x && !y)  puts(" -- is a regular palindrome.");
        else if(y && !x)  puts(" -- is a mirrored string.");

        puts("");
    }
    return 0;
}

bool p(char * x)
{
    int left = 0 , right = strlen(x)-1;
    while(left<=right)
        if(x[left++]!=x[right--])   return 0;
    return 1;
}

bool m(char * x)
{
    int left = 0 , right = strlen(x)-1;
    while(left<=right)
        if(mp[x[left++]]!=x[right--])   return 0;
    return 1;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值