比赛 |
20110722 |
评测结果 |
AWAAWAAWAWA |
题目名称 |
解析程序 |
最终得分 |
63 |
用户昵称 |
PurpleShadow |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2011-07-22 10:32:17 |
显示代码纯文本
#include <cstdio>
const int N=5001;
bool END,ERROR;
char s1[N],s2[N];
void work()
{
bool on=0;int l2=0,l1;
int test;char ch;
for (;;)
{
if ((test=getchar())==EOF){END=1;break;}
ch=char(test);
if (on)
{
if (ch=='"')
{
ch=getchar();
if (ch=='"') s1[l1++]='"';else
{
ungetc(ch,stdin);
for (;;)
{
ch=getchar();
if (ch!=','&&ch!=' '&&ch!='\n')
{
ungetc(ch,stdin);
break;
}
}
on=0;
s1[l1]=0;
printf("%s\n",s1);
continue;
}
}
else
s1[l1++]=ch;
}
else
{
if (ch==' '||ch==' ')
if (l2==0) continue;
if (ch=='"') {l1=0;on=1;continue;}
if (ch==','||ch=='\n')
{
while (l2>0&&(s2[l2-1]==' '||s2[l2-1]==' ')) --l2;
s2[l2]=0;
printf("%s\n",s2);
l2=0;
if (ch==',') continue;else break;
}
s2[l2++]=ch;
}
}
if (on&&END) ERROR=1;
}
int main()
{
freopen("parser.in","r",stdin);
freopen("parser.out","w",stdout);
END=0;
do
{
work();
if (ERROR)
{
freopen("parser.out","w",stdout);
printf("Wrong Format\n");
return 0;
}
}while (!END);
return 0;
}