HDOJ HDU 1073 Online Judge

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 5000
using 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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值