• HDU1073 Online Judge【输入输出+字符串】


    Online Judge

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 8329    Accepted Submission(s): 3085

    Problem Description
    Ignatius is building an Online Judge, now he has worked out all the problems except the Judge System. The system has to read data from correct output file and user's result file, then the system compare the two files. If the two files are absolutly same, then the Judge System return "Accepted", else if the only differences between the two files are spaces(' '), tabs(' '), or enters(' '), the Judge System should return "Presentation Error", else the system will return "Wrong Answer".

    Given the data of correct output file and the data of user's result file, your task is to determine which result the Judge System will return.
    Input
    The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
    Each test case has two parts, the data of correct output file and the data of the user's result file. Both of them are starts with a single line contains a string "START" and end with a single line contains a string "END", these two strings are not the data. In other words, the data is between the two strings. The data will at most 5000 characters.
    Output
    For each test cases, you should output the the result Judge System should return.
    Sample Input
    4 START 1 + 2 = 3 END START 1+2=3 END START 1 + 2 = 3 END START 1 + 2 = 3 END START 1 + 2 = 3 END START 1 + 2 = 4 END START 1 + 2 = 3 END START 1 + 2 = 3 END
    Sample Output
    Presentation Error Presentation Error Wrong Answer Presentation Error
    Author
    Ignatius.L

    问题链接HDU1073 Online Judge

    题意简述:参见上文。

    问题分析:这是一个有关输入输出以及字符串处理的问题。

    程序说明:(略)

    题记:(略)


    AC的C++语言程序如下:

    /* HDU1073 Online Judge */
    
    #include <iostream>
    #include <string.h>
    
    using namespace std;
    
    const string START = "START";
    const string END = "END";
    const int N = 5000;
    
    string a1, a2;
    char b1[N+1], b2[N+1];
    
    void input(string& a, char b[])
    {
        string s;
    
        getline(cin, s);
        while(s != START)
            getline(cin, s);
    
        a = "";
        while(getline(cin, s)) {
            if(s == END)
                break;
            a += s + "
    ";
        }
    
        int i = 0, j = 0;
        while(a[i])
            if(a[i] != ' ' && a[i] != '	' && a[i] != '
    ')
                b[j++] = a[i++];
            else
                i++;
        b[j] = '';
    }
    
    int main()
    {
        int t;
    
        cin >> t;
        while(t--) {
            input(a1, b1);
            input(a2, b2);
    
            if(a1 == a2)
                printf("Accepted
    ");
            else if( strcmp(b1, b2) == 0)
                printf("Presentation Error
    ");
            else
                printf("Wrong Answer
    ");
        }
    
        return 0;
    }


  • 相关阅读:
    MVC开发之排球计分(四)View的设计与实现
    MVC开发之排球计分(三)模型类与设计的实现
    MVC开发之排球计分(二)架构的概要设计
    MVC开发之排球计分(一)排球计分规则说明
    排球比赛计分程序
    MVC排球比赛计分程序之拓展
    MVC之排球比赛计分程序 ——(八)具体代码(1)
    MVC之排球比赛计分程序 ——(八)具体代码(2)
    MVC之排球比赛计分程序 ——(九)总结
    MVC之排球比赛计分程序 ——(四)视图的设计与实现
  • 原文地址:https://www.cnblogs.com/tigerisland/p/7563632.html
Copyright © 2020-2023  润新知