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

【好心人看看】样例能过 为什么输出格式错误???

Posted by john081201 at 2009-03-04 17:21:43 on Problem 2608
#include<stdio.h>
#include<string.h>
char a[21];
int b[21];
int main()
{
	int i;
	while(gets(a)!=EOF)
	{
		memset(b,0,sizeof(b));
		for(i=0;i<strlen(a);i++)
		{
			if(a[i-1]!=a[i]||i==0)
			{
			if(a[i]=='B'||a[i]=='F'||a[i]=='P'||a[i]=='V')
				b[i]=1;
			else if(a[i]=='C'||a[i]=='G'||a[i]=='J'||a[i]=='K'||a[i]=='Q'||a[i]=='S'||a[i]=='X'||a[i]=='Z')
				b[i]=2;
			else if(a[i]=='D'||a[i]=='T')
				b[i]=3;
			else if(a[i]=='L')
				b[i]=4;
			else if(a[i]=='M'||a[i]=='N')
				b[i]=5;
			else if(a[i]=='R')
				b[i]=6;
			}
		}
		if(b[0]!=0)
			printf("%d",b[0]);
		for(i=1;i<strlen(a);i++)
		{
			if(b[i]!=0&&b[i-1]!=b[i])
				printf("%d",b[i]);
		}
		printf("\n");
	}
	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