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的吧

Posted by 00448264 at 2005-08-05 01:07:27 on Problem 1016
In Reply To:请问过路大哥,为什么会在输入多个数据,然后再输入-1结束程序时,会出现错误?当不输入数据,直接输入-1时,程序能正常结束!!感激不尽,我实在被弄的不行了。谢谢 Posted by:iowyh at 2005-08-05 00:59:35
> #include<stdio.h>
> #include<string.h>
> void main()
> {
> 	char p[16][100];
> 	char m[10],temp[3];
> 	int i,j,k,flag;
> 	scanf("%s",p[0]);
> 	while(strcmp(p[0], "-1"))
> 	{   
> 		flag=1;
> 		for(i=0;i<=15;i++)
> 		{
> 			p[i+1][0]='\0';
> 			for(j=0;j<10;j++)
> 				m[j]=0;
> 			for(k=0;p[i][k]!='\0';k++)
> 				m[p[i][k]-'0']++;
> 			for(j=0;j<10;j++)
> 			{
> 				if(m[j]!=0)
> 				{
> 					temp[0]=m[j]+'0';
> 					temp[1]=j+'0';
> 					temp[2]='\0';
> 					strcat(p[i+1],temp);
> 				}
> 			}
>               
> 		}
> 		  if(strcmp(p[0],p[1])==0) {printf("%s is self-inventorying\n",p[0]); flag=0;}
> 
>        for(i=2;i<=15&&flag==1;i++)
> 	   {
> 	        
> 	        if(strcmp(p[i],p[i-1])==0) {printf("%s is self-inventorying after %d steps\n",p[0],i-1);   break;}
> 			for(k=i-1;k>=0;k--)
>         	if(strcmp(p[i],p[k])==0) {printf("%s enters an inventory loop of length %d\n",p[0],i-k);flag=0; break;}
> 			
> 			
> 		}	
> 		if(i==16)  printf("%s can not be classified after 15 iterations\n",p[0]);
> 			scanf("%s",p[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