zjfc----1076 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('\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.
输入描述
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.
输出描述
For each test cases, you should output the the result Judge System should return.
样例输入
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
样例输出
Presentation Error Presentation Error Wrong Answer Presentation Error
#include<stdio.h>
#include<string.h>
char a[5005],b[5005],tmp[5005];
int t;
void input(char *str)
{
getchar();
gets(tmp);
str[0]='\0';
while(gets(tmp)&&strcmp(tmp,"END")){
if(strlen(tmp)==0)
strcat(str,"\n");
else
strcat(str,tmp);
}
}
void mdo(char *s)
{
int i,j;
int len=strlen(s);
for(i=0,j=0;i<len;i++){
if(s[i]==' '||s[i]=='\t'||s[i]=='\n')
continue;
tmp[j++]=s[i];
}
tmp[j]='\0';
strcpy(s,tmp);
}
int process()
{
mdo(a);mdo(b);
if(strcmp(a,b)==0)
return 1;
return 0;
}
int main()
{
scanf("%d",&t);
while(t--){
input(a);
input(b);
if(strcmp(a,b)==0)
printf("Accepted\n");
else if(process())
printf("Presentation Error\n");
else
printf("Wrong Answer\n");
}
}
转载于:https://www.cnblogs.com/pandy/archive/2009/04/30/1447249.html
zjfc----1076 online judge 对多行字符串输入做处理相关推荐
- C语言多行字符串输入问题
C语言多行字符串输入问题 不明确具体输入行数 对于没有确定的输入行数时,一般采用Ctrl+Z结束输入. 对于输入多个字符串,可以保存在二维数组中 1.~scanf方式 char str[100][10 ...
- python多行字符串输入_python中怎么输入多行字符串
python中怎么输入多行字符串,疾风,不言,努力,人生,起风了 python中怎么输入多行字符串 易采站长站,站长之家为您整理了python中怎么输入多行字符串的相关内容. Python中输入多行字 ...
- Redis 笔记(11)— 文本协议 RESP(单行、多行字符串、整数、错误、数组、空值、空串格式、telnet 登录 redis)
RESP 是 Redis 序列化协议Redis Serialization Protocol 的简写.它是一种直观的文本协议,优势在于实现异常简单,解析性能极好. Redis 协议将传输的结构数据 ...
- python跨行字符串 变量_在Python中有没有在多行字符串中使用变量的方法?
所以我把这个作为邮件发送脚本的一部分:try: content = ("""From: Fromname To: Toname MIME-Version: 1.0 Con ...
- 【廖雪峰python入门笔记】raw 字符串和多行字符串表示
1. raw 字符串 描述 如果一个字符串包含很多需要转义的字符,对每一个字符都进行转义会很麻烦. 为了避免这种情况,我们可以在字符串前面加个前缀 r,表示这是一个 raw 字符串,里面的字符就不需要 ...
- java编写字符串连接程序注释_一种利用JAVA注释支持多行字符串的方法
从BeetlSql项目将SQL全放在Beetl模板里得到启发,又想到一个比较偏门的用法.以下代码实测通过,详见jSqlBox项目的test\examples\multipleLineSQL\SqlTe ...
- 多行字符串,带有多余的空格(保留缩进)
本文翻译自:Multi-line string with extra space (preserved indentation) I want to write some pre-defined te ...
- 如何在Go中编写多行字符串?
本文翻译自:How do you write multiline strings in Go? Does Go have anything similar to Python's multiline ...
- 在JavaScript中创建多行字符串
我在Ruby中有以下代码. 我想将此代码转换为JavaScript. JS中的等效代码是什么? text = <<"HERE" This Is A Multiline ...
最新文章
- cmake 添加头文件目录,链接动态、静态库
- Eclipse中安装freemarker插件
- 数据库开发——MySQL——慢查询优化
- 如何使用JSON和Servlet创建JQuery DataTable
- Command ‘ifconfig‘ not found, but can be installed with: sudo apt install net-tools VM Ubuntu 解决方案
- 安卓端和IOS端小程序蓝牙通讯问题
- 游戏开发完整学习路线,都在这里了
- 教你分辨真假苹果官方售后维修点就是这么简单!!
- dropbox 怎么使用_如何在Android手机上使用Dropbox
- 编解码学习笔记(九):QuickTime系列
- 信息系统项目管理师(2022年) —— 第 3 章 项目立项管理
- Buct oj 1015
- Redis简介及优势
- 服务器snb芯片组,技嘉发布三款SNB Xeon单路服务器主板
- html 按钮禁用状态,按钮状态——禁用状态
- 阿ken的HTML、CSS的学习笔记_表单的应用(笔记七)
- web前端各种浏览器版本测试工具-turbo
- DM365的视频编码器的硬件设计
- php $_files怎么上传,如何利用​PHP中的 $_FILES上传文件
- 第二届赣网杯WEB第一题WP
热门文章
- 拥抱夏天的方式有很多,来这12处避暑凉爽整个夏天
- java执行sql列名无效_列名无效!java代码里的SQL语句!数据库里可以得到正确为什么放java里出错了?...
- 磊科路由器信号按键_磊科无线路由操作手册
- 看到这4种奇葩面试方法的公司,转身就走吧!
- java awt 显示图片_Java开发笔记(一百二十三)AWT图像视图
- 科学家发现病毒感染细胞和染色体密切相关,提取出这些染色体的最大相似之处
- 2022年龙岩市高新技术企业奖励补贴,高企网上申报流程是什么?
- IT领域仍是风投宠儿
- 香港科技大学计算机博导陈,香港科技大学计算机科学及工程系丁存生教授访问我校...
- curl_操作nuetron下的mysql数据(资源数据)