首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【南理oj】218 - Dinner (水)

【南理oj】218 - Dinner (水)

作者头像
FishWang
发布2025-08-26 19:25:16
发布2025-08-26 19:25:16
9300
代码可运行
举报
运行总次数:0
代码可运行

Dinner

时间限制: 100 ms | 内存限制: 65535 KB

难度: 1

描述 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. 样例输入

代码语言:javascript
代码运行次数:0
运行
复制
3 basketball fork chopsticks
2 bowl letter

样例输出

代码语言:javascript
代码运行次数:0
运行
复制
fork chopsticks
bowl

提示 The tableware only contains: bowl, knife, fork and chopsticks. 来源 辽宁省10年省赛 上传者 ACM_李如兵

水。

代码如下:

代码语言:javascript
代码运行次数:0
运行
复制
#include <stdio.h>
#include <string.h>
int main()
{
	int n;
	char a[44];
	while (~scanf ("%d",&n))
	{
		while (n--)
		{
			scanf ("%s",a);
			if (!strcmp(a,"bowl"))
			{
				printf ("bowl");
				if (n)
				printf (" ");
			}
			else if (!strcmp(a,"knife"))
			{
				printf ("knife");
				if (n)
				printf (" ");
			}
			else if (!strcmp(a,"fork"))
			{
				printf ("fork");
				if (n)
				printf (" ");
			}
			else if (!strcmp(a,"chopsticks"))
			{
				printf ("chopsticks");
				if (n)
				printf (" ");
			}
		}
		printf ("\n");
	}
	return 0;	
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2025-08-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Dinner
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档