NYOJ-Dinner

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.
样例输入
3 basketball fork chopsticks
2 bowl letter
样例输出
fork chopsticks
bowl
提示
The tableware only contains: bowl, knife, fork and chopsticks.

 1 #include <stdio.h>
 2 #include <string.h>
 3 int main(void){
 4     int N,flag; char s[100];
 5     char dis[][11]={"bowl", "knife", "fork", "chopsticks"};
 6     while(scanf("%d",&N) != EOF){
 7         flag = 0;///控制空格的输出
 8         while(N--){
 9             scanf("%s",s);
10             for(int i = 0; i < 4; i++){
11                 if(strcmp(s,dis[i]) == 0){
12                     if(flag != 0)
13                         printf(" ");
14                     printf("%s",s);
15                     flag = 1;
16                 }
17             }
18         }
19         printf("\n");
20     }
21     return 0;
22 }

时间: 2024-08-08 19:19:57

NYOJ-Dinner的相关文章

水题 第四站 NYOJ Dinner

同样感觉受到了贪心的欺骗,使用C++的string写的,果断超时,忘记了strcmp这个比较字符串的函数 我的代码 1 #include <iostream> 2 #include <stdio.h> 3 #include <math.h> 4 #include <algorithm> 5 #include <string.h> 6 using namespace std; 7 8 int main () 9 { 10 int n; 11 str

nyoj 218 Dinner(水题)

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

NYOJ 218 Dinner

#include<stdio.h>#include<string.h>int main(){ int n,i,k; char str[10],s[1010][10]; while(scanf("%d",&n)!=EOF) { k=0; memset(s,0,sizeof(s)); for(i=0;i<n;i++) { scanf("%s",str); if(strcmp(str,"bowl")==0 ||st

NYOJ 237 游戏高手的烦恼 &amp;&amp; POJ3041-Asteroids ( 二分图的最大匹配 )

链接: NYOJ 237  游戏高手的烦恼:click here~~ POJ  3041 Asteroids           :click here~~ 题意: 两题一样,翻译不同而已. 有一位传说级游戏高手,在闲暇时间里玩起了一个小游戏,游戏中,一个n*n的方块形区域里有许多敌人,玩家可以使用炸弹炸掉某一行或者某一列的所有敌人.他是种玩什么游戏都想玩得很优秀的人,所以,他决定,使用尽可能少的炸弹炸掉所有的敌人. 现在给你一个游戏的状态,请你帮助他判断最少需要多少个炸弹才能炸掉所有的敌人吧.

NYOJ 49 开心的小明

开心的小明 时间限制:1000 ms  |  内存限制:65535 KB 难度:4 描述 小明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间.更让他高兴的是,妈妈昨天对他说:"你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过N 元钱就行".今天一早小明就开始做预算,但是他想买的东西太多了,肯定会超过妈妈限定的N 元.于是,他把每件物品规定了一个重要度,分为5 等:用整数1~5 表示,第5 等最重要.他还从因特网上查到了每件物品的价格(都是整数元).

NYOJ 106 背包问题

背包问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 现在有很多物品(它们是可以分割的),我们知道它们每个物品的单位重量的价值v和重量w(1<=v,w<=10):如果给你一个背包它能容纳的重量为m(10<=m<=20),你所要做的就是把物品装到背包里,使背包里的物品的价值总和最大. 输入 第一行输入一个正整数n(1<=n<=5),表示有n组测试数据: 随后有n测试数据,每组测试数据的第一行有两个正整数s,m(1<=s<=10

NYOJ 289 苹果

苹果 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 ctest有n个苹果,要将它放入容量为v的背包.给出第i个苹果的大小和价钱,求出能放入背包的苹果的总价钱最大值. 输入 有多组测试数据,每组测试数据第一行为2个正整数,分别代表苹果的个数n和背包的容量v,n.v同时为0时结束测试,此时不输出.接下来的n行,每行2个正整数,用空格隔开,分别代表苹果的大小c和价钱w.所有输入数字的范围大于等于0,小于等于1000. 输出 对每组测试数据输出一个整数,代表能放入背包的苹

nyoj 括号匹配

这个方程有两种形式,本文采用 if(s[i]=s[j]) dp[i][j]=d[i-1][j-1] dp[i][j]=min(dp[i][k]+dp[k+1][j],dp[i][j]) (i=<k<j) 其实与另一种方法比较:根据j的所有匹配情况取最小值 1.i到j无匹配,取为dp[i][j-1]+1 2.列举所有匹配情况 dp[i][k-1]+dp[k+1][j] 取上述所有情况最小值 两者都能获得正确的结果. 同时两者的初始化为 dp[i][j]==1 if(i==j) 规划方向为:  

NYOJ 461-Fibonacci数列(四)(求斐波那契数列前4位)

题目地址:NYOJ 461 思路:斐波那契数列的通项公式为 然后下一步考虑如何产生前4位: 先看对数的性质,loga(b^c)=c*loga(b),loga(b*c)=loga(b)+loga(c);假设给出一个数10234432, 那么log10(10234432)=log10(1.0234432*10^7)[用科学记数法表示这个数]=log10(1.0234432)+7; log10(1.0234432)就是log10(10234432)的小数部分. log10(1.0234432)=0.0

NYOJ 527 AC_mm玩dota

AC_mm玩dota 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描述 大家都知道AC_mm比较喜欢玩游戏,特别是擅长war3这款经典游戏.某天AC_mm来到了VS平台上 ,准备去虐菜鸟,正巧一个不小心将我们ACM队长虐了 ^_^,我们的队长这下可不高兴了,说要出一道难题让AC_mm难堪一下.题目描述是这样的,给一个正整数n,n在二进制表示的情况下(不含前导0和符号位)有a个1和b个0,求斐波拉契数列的第a*b项对1314520取模后的值ans. 注意(斐波拉契数列: