hdu1073
Online Judge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5376 Accepted Submission(s): 2056
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('\t'), or enters('\n'), 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.
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.
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题目分析:题目大意就是让做一个简单的字符串判断程序。做着做着我就遇到一个问题,就是不知道怎么处理换行符,看了别人的代码我知道了strcat这个函数做这道题目的时候需要注意结束符跟换行符。代码如下:#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; char str1[10000]; char str2[10000]; char zifu1[10000]; char zifu2[10000]; char temp[10000]; void input(char a[],char b[]){ //定义一个函数,处理输入输出,及对字符串的处理 gets(temp); while(strcmp(temp,"START")!=0) gets(temp); while(gets(temp)){ if(strcmp(temp,"END")==0) break; if(strlen(temp)!=0) strcat(a,temp); strcat(a,"\n"); //加入换行符 } int num; num=strlen(a); int k=0; for(int i=0;i<num;i++) if(a[i]!='\t'&&a[i]!='\n'&&a[i]!=' ') b[k++]=a[i]; b[k]='\0'; //加入结束符 } int main(){ int i,j,k,t; int num1,num2; int N; scanf("%d",&N); while(N--){ str1[0]='\0'; str2[0]='\0'; input(str1,zifu1); input(str2,zifu2); if(strcmp(str1,str2)==0) printf("Accepted\n"); else if(strcmp(zifu1,zifu2)==0) printf("Presentation Error\n"); else printf("Wrong Answer\n"); } return 0; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理