HDOJ HDU 1073 Online Judge

来源:互联网 发布:成都网络推广培训 编辑:程序博客网 时间:2024/06/18 12:26

HDOJ 1073 Online Judge

题目

点此查看 HDOJ 1073 Online Judge

分类

字符处理

题意

写个OJ判题程序
Accepted: 提交和答案完全相同
 Presentation Error : 提交和答案只有 空格 ’  ’  制表符tab ‘\t’ 或 回车 ‘\n’ 不同
Wrong Answer : 不符合以上条件

题解

我的思路
先将两组数据全部读入string(包括所有回车、tab、换行)
如果两组数据完全一致则AC
否则将两组数据的格式字符(包括所有回车、tab、换行)
如果经过上述处理的字符串完全一致则PE,否则AW

代码

#include <iostream>#include <cstring>#define maxn 5000using namespace std;string a;string b;bool isdel(char ch);bool ispe();int main(){    int n;    string s;    cin >> n;    cin.get();    while(n--)    {        a.clear();        b.clear();        while(getline(cin,s) && s != "START");        while(getline(cin,s))        {            if(s == "END")                break;            a += s;            a += '\n';        }//        cout << a <<endl;        while(getline(cin,s) && s != "START");        while(getline(cin,s))        {            if(s == "END")                break;            b += s;            b += '\n';        }//        cout << b << endl;        if(a.length() == b.length() && a == b)        {            cout << "Accepted" << endl;            continue;        }        if(ispe())            cout << "Presentation Error" << endl;        else            cout << "Wrong Answer" << endl;    }    return 0;}bool ispe(){    string aj;    string bj;    for(int i = 0;i < a.length();i++)        if(isdel(a[i]))            aj += a[i];    for(int i = 0;i < b.length();i++)        if(isdel(b[i]))            bj += b[i];    if(aj == bj)        return true;    else return false;}bool isdel(char ch){    if(ch != ' ' && ch != '\t' && ch != '\n')        return true;    return false;}