zoukankan      html  css  js  c++  java
  • Dinner http://acm.nyist.net/JudgeOnline/problem.php?pid=218

     

    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.
    来源
    辽宁省10年省赛
    #include<stdio.h>
    #include<string.h>
    int main()
    {
    	int n;
    	while(scanf("%d",&n)!=EOF)
    	{
    			char a[100][20];
    			int i,len;
    			for(i=0;i<n;i++)
    			{
    				getchar();
    				len=1;
    				scanf("%s",a[i]);
    				if(a[i][0]=='b'&&a[i][1]=='o'&&a[i][2]=='w'&&a[i][3]=='l')
    					printf("bowl");
    				else if(a[i][0]=='k'&&a[i][1]=='n'&&a[i][2]=='i'&&a[i][3]=='f'&&a[i][4]=='e')
    					printf("knife");
    				else if(a[i][0]=='f'&&a[i][1]=='o'&&a[i][2]=='r'&&a[i][3]=='k')
    					printf("fork");
    				else if(a[i][0]=='c'&&a[i][1]=='h'&&a[i][2]=='o'&&a[i][3]=='p'&&a[i][4]=='s'&&a[i][5]=='t'&&a[i][6]=='i'&&a[i][7]=='c'&&a[i][8]=='k'&&a[i][9]=='s')
    					printf("chopsticks");
    				else
    					len=0;
    				if(i==n-1)
    					printf("
    ");
    				else if(len!=0)
    					printf(" ");
    			}
    	}
    	return 0;
    }
    

    很好写的一道题,注意输出的空格和换行。还有getchar的位置。

  • 相关阅读:
    Charles:rewrite重写功能
    Vue中provide和inject 用法
    vue中install方法
    vue自定义组件(通过Vue.use()来使用)即install的使用
    Eelectron 中的remote模块
    理解Vue中的Render渲染函数
    Vue.js中this.$nextTick()的使用
    postman请求本地接口Error: connect ECONNREFUSED 127.0.0.1:8083
    1016 Phone Bills (25 分)
    CF842E Nikita and game
  • 原文地址:https://www.cnblogs.com/wangyouxuan/p/3267038.html
Copyright © 2011-2022 走看看