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 }
  • 相关阅读:
    Zookeeper白话解析
    WireMock简单使用
    mysql通用包安装
    修改mysql密码
    jmeter for循环嵌套if学习2
    jmeter for循环嵌套if学习1
    jmeter Transaction Controller学习
    jmeter ForEach Controller学习
    loadrunner随笔1
    shell中创建mysql库和执行sql脚本
  • 原文地址:https://www.cnblogs.com/zn505119020/p/3584047.html
Copyright © 2011-2022 走看看