nyoj_218_Dinner_201312021434
Dinner
- 描述
- 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.
- 来源
- 辽宁省10年省赛
#include <stdio.h>
#include <string.h> char str[][]; int cmp(const void *a,const void *b)
{
return *(char *)a - *(char *)b;
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int i,j,k;
getchar();
for(i=;i<n;i++)
scanf("%s",str[i]);
//qsort(str,n,sizeof(str[0]),cmp);
//for(i=0;i<n;i++)
//puts(str[i]);
for(k=,i=;i<n;i++)
{
if(strcmp(str[i],"bowl")==)
{
if(k)
printf(" ");
printf("%s",str[i]);
k++;
}
else if(strcmp(str[i],"chopsticks")==)
{
if(k)
printf(" ");
printf("%s",str[i]);
k++;
}
else if(strcmp(str[i],"fork")==)
{
if(k)
printf(" ");
printf("%s",str[i]);
k++;
}
else if(strcmp(str[i],"knife")==)
{
if(k)
printf(" ");
printf("%s",str[i]);
k++;
}
}
printf("\n");
}
return ;
}
//比我想象的简单
nyoj_218_Dinner_201312021434的更多相关文章
随机推荐
- 如何通过XInput技术针对游戏方向盘或者手柄编程
目前市面上的游戏外设,要么支持传统的DirectInput接口,要么支持最新的XInput技术.今天在这里聊一聊,如何通过XInput技术实现对这类游戏外设相关信息的捕获.关于DirectInput与 ...
- 一、Linux文件权限与目录配置
行文结构如下: 用户和用户组 Linux文件权限概念 Linux目录配置 重点回顾 1.用户与用户组 Linux是个多用户.多任务的系统,可能有多人同时使用这台机器进行工作,为了考虑每个人的隐私和工作 ...
- JavaScript 中String和int互相转换
在javascript里怎么样才能把int型转换成string型 (1) var num = 0; a = x.toString(); (2) var x = 0; a = x + ...
- php打包文件夹成zip文件
function addFileToZip($path,$zip){ $handler=opendir($path); //打开当前文件夹由$path指定. while(($filenam ...
- [Swift通天遁地]四、网络和线程-(12)使用ReachabilitySwift实现对网络状态的检测
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- [Swift通天遁地]七、数据与安全-(12)使用Instruments Leaks工具检测内存泄露
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- 【洛谷2926/BZOJ1607】[USACO08DEC]Patting Heads拍头(筛法)
题目: 洛谷2926 (截止至本博客发表时,BZOJ1607题面有误,正确题面请到洛谷2926查看) 分析: = 一句话题意:给定\(n\)个数\(\{a_i\}\),求对于每个\(a_i\)有多少个 ...
- 传值:web.xml传递参数 即在Servlet中获取web.xml里的值
传值:web.xml传递参数 在web.xml中的Servlet里配置多个init-param <servlet> ... <init-param> <param-nam ...
- 一篇文章告诉你如何使用EF CodeFirst做增删改查
一.修改数据 其实修改涉及的内容挺多的,是相对于其他操作来说比较繁琐.也是本文的重头戏. 虽然都是基础内容,但是也是值得细细品味的. 1.最简单直接的修改数据就是从数据库里检索出数据修改相应的字段即可 ...
- webSocket客服在线交谈
一>用户端 <%@ page language="java" pageEncoding="UTF-8" %><%@ taglib uri ...