博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ningbo [1217] Dinner(简单题,但是注意输出,pe3遍)
阅读量:4037 次
发布时间:2019-05-24

本文共 2252 字,大约阅读时间需要 7 分钟。

1、

注意输出,中间有空格,最后没有,处理空格错了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 chopsticks2 bowl letter
  • 样例输出
  • fork chopsticksbowl
  • 提示
  • The tableware only contains: bowl, knife, fork and chopsticks.
  • 来源
  • 辽宁省赛2010
3、AC代码:

#include
#include
#include
#include
#include
using namespace std;#define N 1005char 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;}

转载地址:http://agddi.baihongyu.com/

你可能感兴趣的文章
昨夜今晨最大八卦终于坐实——人类首次直接探测到了引力波
查看>>
如何优雅、机智地和新公司谈薪水?
查看>>
为什么读了很多书,却学不到什么东西?
查看>>
长文干货:如何轻松应对工作中最棘手的13种场景?
查看>>
如何用好碎片化时间,让思维更有效率?
查看>>
No.147 - LeetCode1108
查看>>
No.174 - LeetCode1305 - 合并两个搜索树
查看>>
No.175 - LeetCode1306
查看>>
No.176 - LeetCode1309
查看>>
No.182 - LeetCode1325 - C指针的魅力
查看>>
mysql:sql create database新建utf8mb4 数据库
查看>>
mysql:sql alter database修改数据库字符集
查看>>
mysql:sql drop table (删除表)
查看>>
mysql:sql truncate (清除表数据)
查看>>
scrapy:xpath string(.)非常注意问题
查看>>
yuv to rgb 转换失败呀。天呀。谁来帮帮我呀。
查看>>
yuv420 format
查看>>
YUV420只绘制Y通道
查看>>
yuv420 还原为RGB图像
查看>>
LED恒流驱动芯片
查看>>