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;
}
    
相关推荐
Hello--_--World12 分钟前
ES13:类私有属性和方法、顶层 await、at() 方法、Object.hasOwnProperty()、类静态块 相关知识点
开发语言·javascript·es13
Hugh-Yu-13012320 分钟前
二元一次方程组求解器c++代码
开发语言·c++·算法
weixin_5206498725 分钟前
C#进阶-特性全知识点总结
开发语言·c#
文祐27 分钟前
C++类之虚函数表及其内存布局
开发语言·c++
编程大师哥44 分钟前
C++类和对象
开发语言·c++·算法
M158227690551 小时前
工业 CAN 总线无线互联利器|4 路 CAN 转 4G/WiFi 网关 产品介绍
开发语言·php
burning_maple1 小时前
AI 工程实战指南:从零开始构建 AI 应用
开发语言·人工智能
fengyehongWorld1 小时前
C# 创建vba用的类库
c#
你的牧游哥1 小时前
Java 核心概念详解
java·开发语言
文祐1 小时前
C++类之虚函数表和虚基类表及其内存布局(一个子类虚继承一个父类)
开发语言·c++