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
  • 相关阅读:
    python 生成白画布,黑画布和指定颜色画布(纯白色图片或黑色图片或纯色图片)(python generate white, black or pure color canva)
    tomcat启动出现乱码
    nicstat命令安装与使用
    sar命令详解【转】
    使用 virtualBox 让虚拟机连接外网
    跟面试官侃半小时MySQL事务,说完原子性、一致性、持久性的实现【转】
    jmeter的HTML Link Parser链路解析器的使用方法
    Jmeter导入badboy的jmx文件后,使用后置处理器的正则表达式提取器提取URL论坛板块ID失败
    Jforum中文版本不能发帖的问题
    部署JForum 2.1.9安装时遇到的问题:报错数据库问题
  • 原文地址:https://www.cnblogs.com/haoabcd2010/p/6953632.html
Copyright © 2011-2022 走看看