hello判断

描述

从键盘输入由5个字符组成的单词,判断此单词是不是hello,并显示结果。

输入

由5个字符组成的单词

输出

输出一句话: "this word is not hello!" 或者 "this word is hello!"。

输入样例 1

hello

输出样例 1

this word is hello!

输入样例 2

lello

输出样例 2

this word is not hello!

python3

python 复制代码
word = input().strip()
if word == "hello":
    print("this word is hello!")
else:
    print("this word is not hello!")    
    

c++

cpp 复制代码
#include <iostream>
#include <string>
#include <algorithm>

int main() {
    std::string word;
    std::cin >> word;

    // 移除首尾空白字符(如果需要)
    // word.erase(0, word.find_first_not_of(" \t"));
    // word.erase(word.find_last_not_of(" \t") + 1);

    if (word == "hello") {
        std::cout << "this word is hello!" << std::endl;
    } else {
        std::cout << "this word is not hello!" << std::endl;
    }

    return 0;
}
    
相关推荐
大飞pkz1 小时前
【设计模式】六大基本原则
开发语言·设计模式·c#·六大原则
iCxhust2 小时前
Intel8259汇编串口接收转C语言
c语言·开发语言·汇编
掘根2 小时前
【Qt】布局管理器
开发语言·qt
半夏知半秋2 小时前
skynet-socket.lua源码分析
服务器·开发语言·学习·架构·lua
西猫雷婶3 小时前
random.shuffle()函数随机打乱数据
开发语言·pytorch·python·学习·算法·线性回归·numpy
来生硬件工程师3 小时前
CH582 GPIO
c语言·开发语言·单片机
椒颜皮皮虾3 小时前
DeploySharp开源发布:让C#部署深度学习模型更加简单
c#·openvino
fly-phantomWing4 小时前
在命令提示符页面中用pip命令行安装Python第三方库的详细步骤
开发语言·python·pip
VBA63374 小时前
VBA数据库解决方案第二十三讲:向一个已有数据表中添加数据记录
开发语言
杜子不疼.5 小时前
【C++】玩转模板:进阶之路
java·开发语言·c++