Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

有谁最近做了这题吗?能帮我看看吗?一直WA……谢谢^_^

Posted by acm_pku at 2007-08-06 09:11:16 on Problem 1590
#include "stdio.h"
#include "string.h"
int check(char *s)
{
	int i;
	for(i=0;s[i];i++)
	{
		
		if(s[i]=='B'||s[i]=='C'||s[i]=='D'||s[i]=='F'||s[i]=='G'||s[i]=='K'||s[i]=='N'||s[i]=='P'||s[i]=='Q'||s[i]=='R'||s[i]=='4'||s[i]=='6'||s[i]=='7'||s[i]=='9'||s[i]=='0')
		{
			return 0;
			break;
		}
	}
	return 1;
}
int palindrome(char *s)
{
	char *p,*q;
	p=s;
	q=s+strlen(s)-1;
	while(p<q)
	{
		if(*p==*q)
		{
			p++;
			q--;
		}
		else
		{
			return 0;
			break;
		}
	}
	return 1;
}
int mirrored(char *s)
{
	int i;
	if(check(s))
	{
	for(i=0;s[i];i++)
	{
		if(s[i]=='E')
			s[i]='3';
		if(s[i]=='J')
			s[i]='L';
		if(s[i]=='S')
			s[i]='2';
	    if(s[i]=='Z')
			s[i]='5';
		
	}
	if(palindrome(s))
		return 1;
	else
		return 0;
	}
	return 0;
}
int main()
{
	char s[25];
	while(scanf("%s",s)!=EOF)
	{
		if(palindrome(s)&&mirrored(s))
			printf("%s %s\n\n",s,"-- is a mirrored palindrome.");
		else if(mirrored(s))
		    printf("%s %s\n\n",s,"-- is a mirrored string.");
		else if(palindrome(s))
			printf("%s %s\n\n",s,"-- is a regular palindrome.");
		else
            printf("%s %s\n\n",s,"-- is not a palindrome.");
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator