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;
}
    
相关推荐
tobebetter95275 小时前
How to manage python versions on windows
开发语言·windows·python
9***P3346 小时前
PHP代码覆盖率
开发语言·php·代码覆盖率
CoderYanger6 小时前
优选算法-栈:67.基本计算器Ⅱ
java·开发语言·算法·leetcode·职场和发展·1024程序员节
jllllyuz6 小时前
Matlab实现基于Matrix Pencil算法实现声源信号角度和时间估计
开发语言·算法·matlab
多多*6 小时前
Java复习 操作系统原理 计算机网络相关 2025年11月23日
java·开发语言·网络·算法·spring·microsoft·maven
p***43487 小时前
Rust网络编程模型
开发语言·网络·rust
ᐇ9597 小时前
Java集合框架深度实战:构建智能教育管理与娱乐系统
java·开发语言·娱乐
梁正雄7 小时前
1、python基础语法
开发语言·python
强化学习与机器人控制仿真8 小时前
RSL-RL:开源人形机器人强化学习控制研究库
开发语言·人工智能·stm32·神经网络·机器人·强化学习·模仿学习
百***48078 小时前
【Golang】slice切片
开发语言·算法·golang