1
START
You are wrong!
END
START
You a
re wrong!
END
应输出 Presentation Error
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
void delspace(string &s) //删除字符串中的空格(' ') tab('\t')
{
int a;
while(1)
{
a=s.find_first_of(" \t"); //返回字符串中第一个与" \t"中字符匹配的位置
if(a==-1)return; //如果没有匹配的,此函数返回-1
s.erase(s.begin()+a,s.begin()+a+1);//迭代器删除法
}
}
int main()
{
//freopen("in.txt","r",stdin); //用于文件输入 方便测试数据
string s1,s2,garbage;
string str1,str2;
int acount;
scanf("%d",&acount);
while(acount--)
{
int line1=0,line2=0;
cin>>garbage;//start
str1="";
str2="";
while(1)
{
getline(cin,s1);//此函数能得到空格 得不到\n
str1+=s1; //注意这样加起来就没有 \n了
if(s1=="END")break;
line1++; //我们维护一个line1变量,看看有多少行
}
cin>>garbage;//start
while(1)
{
getline(cin,s2);
str2+=s2;
if(s2=="END")break;
line2++;
}
if(str1==str2&&line1==line2) //注意是两个条件哦 用最上面的数据测试下就知道为什么了
{
printf("Accepted\n");
continue;
}
delspace(str1);
delspace(str2);
if(str1==str2)
{
printf("Presentation Error\n");
continue;
}
printf("Wrong Answer\n");
}
return 0;
}