UVa OJ 401回文字符串

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *total = "A   3  HIL JM O   2TUVWXY5";
char *dig = "O1SE Z  8 ";

int 
isParlin(char* s)
{
	int len = strlen(s);
	int i = 0;
	char nepu[30] = {0};
	for(;i<len;i++)
		nepu[i] = s[len-1-i];
	nepu[i] = '\0';
	//printf("%s\n", nepu);
	if(strcmp(s, nepu) == 0)
		return 1;
	return 0;			
}

void
chgeZero(char *s)
{
	int len = strlen(s);
	int i = 0;
	for(; i < len; i++)
		if(s[i] == '0')
			s[i] = 'O';
}

int
isMill(char *s)
{
	int len = strlen(s);
	int i = 0;
	char nepu[30] = {0};
	for(; i < len; i++)
		if(s[len-1-i] >= 'A' && s[len-1-i] <= 'Z')
			nepu[i] = total[s[len-1-i]-'A'];
		else if(s[len-1-i] >= '0' && s[len-1-i] <= '9')
			nepu[i] = dig[s[len-1-i]-'0']; 
	nepu[i] = '\0';
	//printf("%s\n", nepu);
	if(strcmp(nepu, s) == 0)
		return 1;
	return 0;	
}


int
main(void)
{
	char in[30] = {0};
	char copy[30] = {0};
	while(scanf("%s", in) != EOF)
	{
		strcpy(copy, in);	
		chgeZero(in);
		int p = isParlin(in);
		int q = isMill(in);
		if( p ==0 && q == 0)
			printf("%s -- is not a palindrome.\n\n", copy);	
		else if( p == 1 && q == 0)
			printf("%s -- is a regular palindrome.\n\n", copy);	
		else if( p == 0 && q == 1)
			printf("%s -- is a mirrored string.\n\n", copy);	
		else if( p == 1 && q == 1)
			printf("%s -- is a mirrored palindrome.\n\n", copy);	
		memset(in, 0, sizeof in );
		memset(copy, 0, sizeof copy);
	}
	return 0;
}

问题1: 在main方法中忘记写 return 0;  Runtime Error

问题2: 没有弄清楚题目的意思,比如说 BBB 不是 镜像字符串


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值