zoukankan      html  css  js  c++  java
  • Online Judge(字符串-格式)

    Online Judge

    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

     

    // 挺好的题,想了一阵,没想到好的方法,看了kuangbin大神的思路,很强, 把' '当字符加进去,再把实际数据分理出来,比较,是个很好的方法

    还是太菜啊,继续刷题!!!

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 #define MX 5005
     4 
     5 char s1[MX],s2[MX];
     6 char data1[MX],data2[MX];
     7 char tmp[MX];
     8 
     9 void input(char *a,char *b)
    10 {
    11     gets(tmp);
    12     while (gets(tmp))
    13     {
    14         if (strcmp(tmp,"END")==0) break;
    15         strcat(a,tmp);
    16         strcat(a,"
    ");
    17     }
    18     int t=0;
    19     int len = strlen(a);
    20     for (int i=0;i<len;i++)
    21     {
    22         if (a[i]!=' '&&a[i]!='	'&&a[i]!='
    ')
    23             b[t++]=a[i];
    24     }
    25     b[t++]='';
    26 }
    27 
    28 int main()
    29 {
    30     int T;
    31     cin>>T;
    32     getchar();
    33     while (T--)
    34     {
    35         s1[0]='';
    36         s2[0]='';
    37         input(s1,data1);
    38         input(s2,data2);
    39         if (strcmp(s1,s2)==0)
    40             printf("Accepted
    ");
    41         else if (strcmp(data1,data2)==0)
    42             printf("Presentation Error
    ");
    43         else
    44             printf("Wrong Answer
    ");
    45     }
    46     return 0;
    47 }
    View Code
  • 相关阅读:
    Linux环境下安装Tigase XMPP Server
    虚拟机几种网络连接方式的区别
    MySQL修改root密码
    Eclipse使用多个Console
    Eclipse导入Java项目时“No projects are found to import”错误的处理
    GitHub上下载源代码的方法
    Tigase XMPP Server的安装
    MySQL的安装与配置
    Windows下查看JDK是否安装以及安装路径
    archive for required library...
  • 原文地址:https://www.cnblogs.com/haoabcd2010/p/6953632.html
Copyright © 2011-2022 走看看