NBUT 1217 Dinner
来源:互联网 发布:哪的java培训学校好 编辑:程序博客网 时间:2024/06/06 19:44
Description
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.
Input
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.
Output
For each test of the input, output all the name of tableware.
Sample Input
3 basketball fork chopsticks
2 bowl letter
Sample Output
fork chopsticks
bowl
Hint
The tableware only contains: bowl, knife, fork and chopsticks.
非常水的字符串比较题!
放到这里来纯粹是为了强调格式,强调格式,强调格式!!!
代码如下:
#include<iostream>#include<cstring>using namespace std;int main(){ char s[4][11]={"bowl","knife","fork","chopsticks"}; int n; while(cin>>n) { int blag=0; for(int i=0;i<n;i++) { char a[30]; cin>>a; for(int j=0;j<4;j++) if(strcmp(a,s[j])==0) { if(!blag) //控制格式,如果输出的字符串为第一个,则直接输出该字符串并做上标记 { cout<<a; blag=1; } else //标记上之后从第二个开始,在输出每个字符串之前先输出一个空格 cout<<" "<<a; } } cout<<endl; //最后输出换行 } return 0;}
注:每个人的控制格式的风格都有不用,在这里只是提出一种建议,一个方法,并不强求。
- NBUT 1217 Dinner
- nbut [1217] Dinner
- NBUT 1217 Dinner
- NBUT 1217 Dinner
- Dinner
- Dinner
- Dinner
- Dinner
- Dinner
- Dinner
- Dinner
- dinner
- Dinner
- Dinner
- Dinner
- Dinner
- Dinner
- Dinner
- Java中的Http连接
- VGG:Very Deep Convolutional Networks for Large-Scale Image Recognition阅读笔记
- 谷歌文档部分翻译:JUnit4 Rules with the ATSL
- OllyDbg捕捉MFC程序按钮事件
- 提高关键词排名的28个SEO技巧
- NBUT 1217 Dinner
- input标签在谷歌浏览器记住密码下的一个自动填充BUG
- 善用GitHub大有助于学习开发
- cocos2d-x 实现目录的遍历 和 文件的全拷贝
- 使用Python连接postgresql数据库
- ie appendChild 意外地调用了方法或属性访问
- 连接数据库的工具类,以及相关用法
- [林轩田]15-验证法
- [Widget]GradientTabStrip-微信式底部渐变栏