C语言之水题

欢迎进入我的C语言世界

题目

Problem Description

胖哥自从当上公务员,赢取白富美,走向人生巅峰后,已经懒散到不想出题了,不仅如此,他连题目都懒得看了,现在他只会根据题目第一个单词的长度判定这个题目的难度

如果题目的第一个单词太长(长度大于3),他会说这题太难,不可能想的出来; 如果题目的第一个单词太短(长度不大于3),他会说这题太简单,懒得去想

现在给定一个题目,L想知道胖哥对于这道题会作出什么反应

Input

首先是一个正整数cas,表示有cas组输入,cas<=100

对于每组输入,会给出一行,每行表示一个题目,每个题目只会由大写字母,小写字母或者空格构成,每行的第一个字符一定不会是空格,多个空格可能连续出现,每行最多200个字符

Output

对于每个题目,如果胖哥觉得这题太难,输出"Too hard!",否则输出"Too easy!"

Sample Input

12
If the day is done
If birds sing no more
If the wind has fiagged tired
Then draw the veil of darkness thick upon me
Even as thou hast wrapt the earth with The coverlet of sleep and tenderly closed
The petals of the drooping lotus at dusk
From the travere
Whose sack of provisions is empty before the voyage is ended
Whose garment is torn and dustladen
Whose strength is exhausted remove shame and poverty
And renew his life like a flower under
The cover of thy kindly night

Sample Output

Too easy!
Too easy!
Too easy!
Too hard!
Too hard!
Too easy!
Too hard!
Too hard!
Too hard!
Too hard!
Too easy!
Too easy!

答案

下面展示 实现代码

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
char arr[207];
int main()
{
    
    
	int n;
//	while( != EOF)
//	{
    
    
		scanf("%d",&n);
		getchar();
		while(n--)
		{
    
    
			memset(arr,0,sizeof(arr));
			gets(arr);
			int len = strlen(arr);
			int num = 0;
			for(int i = 0; i < len; i++)
			{
    
    
				if(arr[i] != ' ')
				{
    
    
					num++;
				}
				else
				{
    
    
					if(num > 3)
					{
    
    
						printf("Too hard!\n");
						break;
					}
					else
					{
    
    
						printf("Too easy!\n");
						break;	
					}
				}
			}
		}
//	}
	return 0;
 } 

本题感悟

本块内容可能来自课本或其他网站,若涉及侵权问题,请联系我进行删除,谢谢大家啦~

今天在收材料,本来很烦不想写的,但是看到一题水题,就写了,还真是名副其实的水题,其实也算是我的一点点小小的倔强吧,我想坚持每天一题,也不知道能坚持多久,且坚持着吧

  1. 用了while(scanf("%d",&n) != EOF)就Time Limit Exceed了
  2. 删掉1的while又忘记getchar()了,就WA了
  3. 整体来说还挺水的,但是思想不错,是这几天学会的新思想(就是用一个num来记录单词数)

以上。

猜你喜欢

转载自blog.csdn.net/hongguoya/article/details/106484317