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 875600 at 2007-06-26 22:29:06 on Problem 2419
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<memory.h>
char s[200][200];
int Comp(const void *p1,const void *p2)
{
	return strcmp((char *)p1,(char *)p2);
}
void main()
{
	int i,j,n,p,sum;
	scanf("%d %d",&n,&p);
	memset(s,'0',sizeof(s));
	for(i=1;i<=n;i++)
		s[i][p+1]='\0';
	while(scanf("%d %d",&i,&j)!=EOF)
	{
	/*	if(i==0&&j==0)
			break;*/
		
		s[i][j]='1';
	}
	qsort(s,n,sizeof(s[0]),Comp);
/*	for(i=1;i<=n;i++)
		printf("%s\n",s[i]);*/
	
	i=1;sum=1;
	while(i<n)
	{
		if(strcmp(s[i],s[i+1])!=0)
			sum++;
		i++;
	}
	printf("%d\n",sum);
}

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