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;
}
    
相关推荐
honder试试7 小时前
焊接自动化测试平台图像处理分析-模型训练推理
开发语言·python
^Rocky7 小时前
JavaScript性能优化实战
开发语言·javascript·性能优化
ponnylv7 小时前
深入剖析Spring Boot启动流程
java·开发语言·spring boot·spring
萧邀人7 小时前
第一课、Cocos Creator 3.8 安装与配置
开发语言
Jayden_Ruan8 小时前
C++逆向输出一个字符串(三)
开发语言·c++·算法
不吃鱼的羊8 小时前
启动文件Startup_vle.c
c语言·开发语言
VBA63379 小时前
VBA之Word应用第四章第二节:段落集合Paragraphs对象(二)
开发语言
点云SLAM9 小时前
C++ 常见面试题汇总
java·开发语言·c++·算法·面试·内存管理
xiaowu08010 小时前
策略模式-不同的鸭子的案例
开发语言·c#·策略模式
edjxj10 小时前
Qt图片资源导入
开发语言·qt