Ningbo [1217] Dinner(简单题,但是注意输出,pe3遍)
2014-02-15 10:20
393 查看
1、http://cdn.ac.nbutoj.com/Problem/view.xhtml?id=1217
注意输出,中间有空格,最后没有,处理空格错了3遍
2、题目:
问题描述
Little A is one member of ACM team. He had just won the gold in World Final. To celebrate, he decided to invite all to have one meal. As bowl, knife and other tableware is not enough in the kitchen, Little A goes to take
backup tableware in warehouse. There are many boxes in warehouse, one box contains only one thing, and each box is marked by the name of things inside it. For example, if "basketball" is written on the box, which means the box contains only basketball. With
these marks, Little A wants to find out the tableware easily. So, the problem for you is to help him, find out all the tableware from all boxes in the warehouse.
输入
There are many test cases. Each case contains one line, and one integer N at the first, N indicates that there are N boxes in the warehouse. Then N strings follow, each string is one name written on the box.
输出
For each test of the input, output all the name of tableware.
样例输入
样例输出
提示
来源
3、AC代码:
注意输出,中间有空格,最后没有,处理空格错了3遍
2、题目:
[1217] Dinner
时间限制: 1000 ms 内存限制: 32768 K问题描述
Little A is one member of ACM team. He had just won the gold in World Final. To celebrate, he decided to invite all to have one meal. As bowl, knife and other tableware is not enough in the kitchen, Little A goes to take
backup tableware in warehouse. There are many boxes in warehouse, one box contains only one thing, and each box is marked by the name of things inside it. For example, if "basketball" is written on the box, which means the box contains only basketball. With
these marks, Little A wants to find out the tableware easily. So, the problem for you is to help him, find out all the tableware from all boxes in the warehouse.
输入
There are many test cases. Each case contains one line, and one integer N at the first, N indicates that there are N boxes in the warehouse. Then N strings follow, each string is one name written on the box.
输出
For each test of the input, output all the name of tableware.
样例输入
3 basketball fork chopsticks 2 bowl letter
样例输出
fork chopsticks bowl
提示
The tableware only contains: bowl, knife, fork and chopsticks.
来源
辽宁省赛2010
3、AC代码:
#include<stdio.h> #include<math.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; #define N 1005 char s[105]; int main() { int n; while(scanf("%d",&n)!=EOF) { int flag=0; for(int i=1; i<=n; i++) { scanf("%s",s); if(flag==0) { if(strcmp(s,"bowl")==0) printf("%s",s),flag=1; else if(strcmp(s,"knife")==0) printf("%s",s),flag=1; else if(strcmp(s,"fork")==0) printf("%s",s),flag=1; else if(strcmp(s,"chopsticks")==0) printf("%s",s),flag=1; } else { if(strcmp(s,"bowl")==0) printf(" %s",s); else if(strcmp(s,"knife")==0) printf(" %s",s); else if(strcmp(s,"fork")==0) printf(" %s",s); else if(strcmp(s,"chopsticks")==0) printf(" %s",s); } } printf("\n"); } return 0; }
相关文章推荐
- new hdoj 1515 (pe)(但是我可以做出来了)(搜索,注意剪枝)
- HDU1017 注意下输出格式就可以了,我因此PE了两次啊!伤不起啊!
- loner_li 机试题 编写一个简单的计算器实现加减乘除:输入两个数字和一个运算符号,输出结果(注意容错性)
- Strange Country II ( 简单的dfs,但是要注意细节)
- UVA116----简单的DP,但是输出路径比较坑
- 哈密顿绕行世界问题 简单的dfs()注意保存输出路径
- 图案打印 (好坑的输出,注意最后一个*后就没有空格了,PE了三遍)
- php输出csv文件 简单实现
- MyEclipse6.5整合flex实现与java简单通信过程中遇到的问题和注意事项
- 《JavaWeb---Servlet的简单例子》---响应浏览器的请求,向浏览器输出数据
- 一个简单的凯撒加密解密程序的fgets函数用法注意
- POJ---2945 Find the Clones[字典树-简单题(多例输入注意删除)]
- 特定字符输出及二分搜索 简单面试编程题
- Java简单从文件读取和输出
- 一步一步使用Ext JS MVC与Asp.Net MVC 3开发简单的CMS后台管理系统之创建输出验证码图片的控制器
- printf 应用注意和 mosquitto loop简单说明
- 编写一个截取字符串的函数,输入为一个字符串和字节数,输出为按字节截取的字符串。 但是要保证汉字不被截半个
- stm32系统在线调试时程序运行正常输出正常,但是一旦把程序烧写进去则输出不正常
- 【计算机导论】程序编码与简单输入/输出
- 高效地输出移动APP产品原型,有哪些方法,要注意哪些?