UVACO401

回文~~~

#include <stdio.h>
#include <string.h>
int is_p(char* s)
{
	int n = strlen(s);
	for(int i = 0; i < n/2; i++)
	{
		if(s[i] != s[n-i-1])
		return 0;
	}
	return 1;
}
int is_mrror(char* s)
{
	const char A[20] = "AMYOHITUVWX18EL25";
	const char B[20] = "AMYOHITUVWX183JSZ";
	int size = strlen(A);
	int n = strlen(s);
	for(int k = 0; k < n; k++)
	{
		if(strchr(A,s[k])==NULL&&strchr(B,s[k])==NULL)
		return 0;
	}
	if(n == 1)
	{
		if(strchr(A,s[0])==NULL)
			return 0;
	}
	else
	{
		for(int i = 0; i < n/2; i++)
		{
			for(int j = 0; j < size; j++)
			{
				if(s[i] == A[j])
				{
					if(s[n-1-i] != B[j]) return 0;
				}
			}
		}
		return 1;
	}
}

int main(int argc, char *argv[]) {
	char s[21];
	memset(s,0,sizeof(s));
	while(scanf("%s",s)==1)
	{
		if((is_p(s))&&(is_mrror(s)))
		printf("%s -- is a mirrored palindrome.\n",s);
		else if((!is_p(s))&&(!is_mrror(s)))
		printf("%s -- is not a palindrome.\n",s);
		else if((is_p(s))&&(!is_mrror(s)))
		printf("%s -- is a regular palindrome.\n",s);
		else if((!is_p(s))&&(is_mrror(s)))
		printf("%s -- is a mirrored string.\n",s);
	}
	return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值