| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求救,wrong answer#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator