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

求救,wrong answer

Posted by 041221125 at 2005-10-27 14:52:24 on Problem 2604
#include<stdio.h>
#include<string.h>
#include<ctype.h>
char s[250][100];
bool newq=false;
int i=0,j,k;
void change()
{
	for(j=0;s[i][j]!='\0';j++)
		if(s[i][j]==34)
		{
			if(j>0&&s[i][j-1]=='\\')continue;
			char t[100];
			strcpy(t,s[i]+j+1);
			if(!newq)
			{
				s[i][j]=s[i][j+1]=96;
				newq=true;
			}
			else
			{
				s[i][j]=s[i][j+1]=39;
				newq=false;
			}
			s[i][j+2]='\0';
			strcat(s[i],t);
		}
}
bool isendofpar()
{
	if(s[i][0]=='\0')return true;
	int l=strlen(s[i])-1;
	while(l>=0&&!isalpha(s[i][l]))l--;
	if(l<3)return false;
	return s[i][l-3]=='\\'&&s[i][l-2]=='p'&&s[i][l-1]=='a'&&s[i][l]=='r';
}
bool isend()
{
	int l=strlen(s[i])-1;
	while(l>=0&&!isalpha(s[i][l]))l--;
	if(l<8)return false;
	return strncmp(s[i]+l-8,"\\endinput",9)==0;
}
int main()
{
	while(true)
	{
		gets(s[i]);
		if(isendofpar()||isend())
		{
			change();
			if(newq)
			{
				for(k=i;;k--){
					for(j=strlen(s[k])-1;j>=0;j--)
						if(s[k][j]==96&&s[k][j+1]==96)break;
					if(s[k][j]==96)break;
				}
				char t[100];
				strcpy(t,s[k]+j+2);
				s[k][j]='\0';
				strcat(s[k],t);
				newq=false;
			}
			for(j=0;j<=i;j++)printf("%s\n",s[j]);
			if(isend())
				break;
			i=0;
			continue;
		}
		change();
		i++;
	}
	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