zoukankan      html  css  js  c++  java
  • hdu 1073 字符串函数的应用

    题目来源:

    http://acm.hdu.edu.cn/showproblem.php?pid=1073

    Online Judge

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


    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
     

     代码如下:

     1 #include<iostream>
     2 #include<stdio.h>
     3 #include<string>
     4 #include<string.h>
     5 #include<map>
     6 #include<math.h>
     7 #include<algorithm>
     8 #define N 5020
     9 using namespace std;
    10 void input(char *s)
    11 {
    12     char tmp[N];
    13     while(gets(tmp) && strcmp(tmp,"END"))
    14     {
    15         if(strlen(tmp)) strcat(s,tmp);
    16         strcat(s,"
    ");
    17     }
    18 }
    19 void Delchar(char *s,int len)
    20 {
    21     char tmp[N];
    22     int t=0;
    23     for(int i=0;i<len;i++)
    24     {
    25         if(s[i]!= ' ' && s[i]!= '	' && s[i] != '
    ')
    26             tmp[t++]=s[i];
    27     }
    28     tmp[t]= '';
    29     strcpy(s,tmp);
    30 }
    31 int main()
    32 {
    33     int t;
    34     scanf("%d",&t);
    35     getchar();      //不能少  ,获得 输入的数字后的 回车
    36     while(t--)
    37     {
    38         char str1[N];
    39         char str2[N];
    40         memset(str1,0,sizeof(str1));
    41         memset(str2,0,sizeof(str2));
    42         int len1,len2;
    43         input(str1);
    44         input(str2);
    45         len1=strlen(str1);
    46         len2=strlen(str2);
    47         if(len1 == len2 && !strcmp(str1, str2)){
    48             printf("Accepted
    ");
    49             continue;
    50         }
    51         Delchar(str1,len1);
    52         Delchar(str2,len2);
    53         if(!strcmp(str1,str2))
    54             puts("Presentation Error");
    55         else
    56             puts("Wrong Answer");
    57 
    58     }
    59 
    60     return 0 ;
    61 }
  • 相关阅读:
    【JavaScript&jQuery】$.ajax()
    【JavaScript&jQuery】5秒跳转
    【数据库_Mysql】Mysql知识汇总
    【Java】时间转json格式化
    【Java】数组升序和降序
    【Java】关于@RequestBody
    未能加载文件或程序集“Oracle.DataAccess”或它的某一个依赖项.试图加载格式不正确的程序
    IIS 7.0、IIS 7.5 和 IIS 8.0 中的 HTTP 状态代码 转
    在IIS7.5上添加.NET4.0程序的虚拟目录时提示ASP.NET 4.0尚未在 Web 服务器上注册
    VC2010 _com_error 返回的错误信息
  • 原文地址:https://www.cnblogs.com/zn505119020/p/3584047.html
Copyright © 2011-2022 走看看