zoukankan      html  css  js  c++  java
  • 杭电 1037 Online Judge 字符处理

    Online Judge

    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

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    int main()
    {
        int l;
        cin>>l;
        getchar();
        while(l--)
        {
            char a[10010],b[10010],c[10010],d[10010],e[10010];
            gets(a);
            memset(b,0,sizeof(b));
            while(gets(a))
            {
                if(strcmp(a,"END")==0) break;
                if(strcmp(a,"END")!=0) strcat(b,a);//链接输入的 字符
                strcat(b,"
    ");//每个句末 都有一个换行
            }
            memset(c,0,sizeof(c));
            gets(a);
            while(gets(a))
            {
                if(strcmp(a,"END")==0) break;
                if(strcmp(a,"END")!=0) strcat(c,a);
                strcat(c,"
    ");
            }
            if(strcmp(b,c)==0)
            {
                printf("Accepted
    ");
                continue;
            }
            int l=strlen(b);
            int h=strlen(c);
            memset(d,0,sizeof(d));
            memset(e,0,sizeof(e));
            int n=0,m=0,i;
            for(i=0;i<l;i++)
            {
                if(b[i]!=' '&&b[i]!='
    '&&b[i]!='	')//保留有效的 字符 去除空格 回车
                    d[n++]=b[i];
            }
            d[n]='';
            for(i=0;i<h;i++)
            {
                if(c[i]!=' '&&c[i]!='
    '&&c[i]!='	')
                    e[m++]=c[i];
            }
            e[m]='';
            if(strcmp(e,d)==0)
                printf("Presentation Error
    ");
            else
                printf("Wrong Answer
    ");
        }
        return 0;
    }
    
  • 相关阅读:
    Springboot+mybatis-plus+mysql+clickhouse集成多数据源
    对集合里每个元素是一个对象,按照对象某一个属性值给这个集合排序
    vue的a-tree-select选择父节点回显的是子节点
    Es简单条件查询
    使用Ant Desigen在vue里面实现分页以及表头的模糊查询
    搭建第一个vue项目
    Address localhost:1099 is already in use
    spring的控制反转DI---基于注解实现
    mybatis下的ResultMap配置一对一以及一对多
    mybatis入门
  • 原文地址:https://www.cnblogs.com/nanfenggu/p/7900189.html
Copyright © 2011-2022 走看看