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:为什么总是PE啊?帮忙看看。

Posted by ihj at 2006-03-16 19:30:35 on Problem 1706
In Reply To:Re:为什么总是PE啊?帮忙看看。 Posted by:cpp00548166 at 2006-03-16 17:34:44
> 因为你如果出现有一行全是空格
> 那么也算一个空行
> 把你的程序修改一下,ac
> #include<stdio.h>
> #include<iostream.h>
> #include<stdlib.h>
> #include<string.h>
> short index[10000];
> bool isetyline(const char* line)
> {
> 	int n=0;
> 	while(*(line+n))
> 	{
> 		if(*(line+n)!=' ')
> 			return false;
> 		n++;
> 	}
> 	return true;
> }
> void main()
> {
> 	short count=0;
> 	char temp[81];
> 	short reindex[10000];
> 	char* refer[10000];//注释段指针
> 	char number[6];
> 	short length=0;
> 	while(gets(temp))
> 	{
> 		if(isetyline(temp))//段间隔空行
>  			continue;
> 		//新注释段
> 		if(temp[0]=='[')
> 		{
> 			for(short i=1;temp[i]!=']';i++)
> 				number[i-1]=temp[i];
> 			number[i-1]='\0';
> 			char *referpara=new char[243];
> 			refer[atoi(number)]=referpara;
> 			short len=strlen(temp);
> 			i++;
> 			for(short j=0;i<len;i++,j++)
> 				referpara[j]=temp[i];
> 			referpara[j]='\n';
> 			j++;
> 			referpara[j]='\0';
> 			while(gets(temp))
> 			{
> 				if(temp[0]=='\0')//段间隔空行
> 					break;
> 				strcat(referpara,temp);
> 				strcat(referpara,"\n");
> 			}
> 			continue;
> 		}
> 		//正文段
> 		do
> 		{
> 			if(isetyline(temp))//段间隔空行
> 				break;
> 			short len=strlen(temp);
> 			for(short i=0;i<len;i++)
> 			{
> 				if(temp[i]=='[')
> 				{
> 					i++;
> 					for(short j=0;temp[i]!=']';j++,i++)
> 						number[j]=temp[i];
> 			 		number[j]='\0';
> 					short num=atoi(number);
> 					if(index[num]==0)//还未注册的索引号
> 					{
> 						count++;
> 						index[num]=count;
> 						reindex[count]=num;
> 					}
> 					printf("[%d]",index[num]);
> 				}
> 				else
> 					printf("%c",temp[i]);
> 			}
> 			printf("\n");
> 		}while(gets(temp));
> 		printf("\n");
> 	}
> 	for(short i=1;i<=count;i++)
> 		printf("[%d]%s\n",i,refer[reindex[i]]);
> 	printf("\n");
> }

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