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

Re:我晕,为什么YES可以就继续输入数据,NO就测试结束?附代码

Posted by 1012fan at 2011-10-06 15:32:32 on Problem 2159
In Reply To:我晕,为什么YES可以就继续输入数据,NO就测试结束?附代码 Posted by:Veegin at 2011-05-10 21:54:36
> 我把别人的输出代码替代我的就AC了,但我就不明白了,题目也没这么别扭的输出要求啊,坑爹啊?!
> 注释的是我自己写的输出。WA死我了。
> #include <iostream>
> #include <string.h>
> #include <stdlib.h>
> using namespace std;
> int cmp(const void *a,const void *b) {return *(int *)b - *(int *)a;}
> int main()
> {
> 	int a[27],b[27],i,len1,len2,flag;
> 	char ch1[150],ch2[150];
> 	while(scanf("%s",ch1)!=EOF)
> 	{
> 		scanf("%s",ch2);
> 		flag=0;len1=strlen(ch1);len2=strlen(ch2);
> 		memset(a,0,sizeof(a));
> 		memset(b,0,sizeof(b));
> 		for(i=0;i<len1;i++) a[ch1[i]-'A']++;
> 		for(i=0;i<len2;i++) b[ch2[i]-'A']++;
> 		qsort(a,27,sizeof(a[0]),cmp);
> 		qsort(b,27,sizeof(b[0]),cmp);
> 		/*for(i=0;i<26;i++) if(a[i]!=b[i]) break;
> 		if(i==26) printf("YES\n");
> 		else printf("N0\n");*/
> 		for(i=0;i<26;i++)
> 			if(a[i]!=b[i])
> 			{
> 				printf("NO\n");
> 				return 0;
> 			}
> 		printf("YES\n");
> 	}
> 	return 0;
> }


因为程序没有被结束,又返回while循环了...

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