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

FT,老是RE,WHY!!!我自己编的测试程序都没有问题(绝对覆盖面够广),请大家帮忙看看!小人感激涕零,救命啊!!!

Posted by C0400004079 at 2004-02-21 13:18:57 on Problem 1002
#include <stdio.h>
#include <stdlib.h>


int sortnum(const void * ,const void * );


int main( int argc, char ** argv )
{
	long count,n,m,o;
	bool rep=false;
 	char str[16],temp[8];
	long numbers[100000];

	int i,d;
	
 	scanf("%ld",&count);
 	for(n=0;n<count;n++)
	{
		scanf("%s",str);
		for(i=0,d=0;str[i]!='\0';i++,d++)
			{	if(str[i]>='A'&&str[i]<'Q')
					str[i]=(char)((str[i]-'A')/3)+'2';
				if(str[i]>'Q'&&str[i]<'Z')
					str[i]=(char)((str[i]-'Q')/3)+'7';
				temp[d]=str[i];
				if(str[i]=='-') d--;
			};
		temp[7]='.';
		numbers[n]=atol(temp);
	};
	
		
	
	qsort(numbers,count,sizeof(long),sortnum);
	
	for(n=0,o=1;n<count-1;n++)
		{
		if(numbers[n]==numbers[n+1])
			o++;
			
		if(numbers[n]!=numbers[n+1]||n==count-2) 
			   if(o>1) 
				{
					sprintf(temp,"%07ld",numbers[n-1]);
					for(i=0;i<7;i++)
					{	if(i==3) printf("-");
						printf("%c",temp[i]);
					};
					printf(" %ld",o);
					printf("\n");
					rep=true;
					o=1;
				};
			    	
			   
			
		};

			
	if(!rep) {
		printf("No duplicates.\n");
		return 0;
		};

	
					
return 0;
}


int sortnum(const void * arg1,const void * arg2)
{
	return  *((long *)arg1)-*((long*)arg2);
};
////////////////////////////////////1002test.cpp///////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//usage:1002test 100000|1002.exe //救命啊!!!!!!
int main(int argc, char **argv)
{
	int d;
	long n;
	time_t mytime=time(0);
		
	srand(localtime(&mytime)->tm_sec);
	sscanf(argv[1],"%d",&n);
	printf("%d\n",n);
	for(int j=0;j<n;j++)		
	{
	for (int i=0;i<7;i++)
	   { if( rand()%2==0 )
		printf("-");
	      d=( rand()%10 );
	     
	      	if(d==0||d==1)
		printf("%d",d); 
	
		if(d>=2&&d<=6)
		  switch( rand()%4 )
		{
		case 0:
		    printf("%d",d);break;
		case 1:
		    printf("%c",(d-2)+'A');break;
		case 2:
		    printf("%c",(d-2)+'B');break;
		case 3:
		    printf("%c",(d-2)+'C');break; 			
		};
		
		if(d>=8&&d<=9)
		  switch( rand()%4 )
		{
		case 0:
		    printf("%d",d);break;
		case 1:
		    printf("%c",(d-8)+'T');break;
		case 2:
		    printf("%c",(d-8)+'U');break;
		case 3:
		    printf("%c",(d-8)+'V');break; 			
		};
		
		if(d==7)
		  switch( rand()%4 )
		{
		case 0:
		    printf("%d",d);break;
		case 1:
		    printf("%c",'P');break;
		case 2:
		    printf("%c",'R');break;
		case 3:
		    printf("%c",'S');break; 			
		};
	  };
	 if( rand()%2==0 )
		printf("-");
	  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