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;
}
    
相关推荐
2zcode38 分钟前
基于Matlab图像处理的静态雨滴去除与质量评估系统
开发语言·图像处理·matlab
胎粉仔1 小时前
Objective-c 初阶——异常处理(try-catch)
开发语言·ios·objective-c
小徐不徐说1 小时前
RTSP协议详解与C++实现实例
开发语言·c++·qt·通信·rtsp
流星白龙2 小时前
【C++算法】75.优先级队列_数据流中的第 K 大元素
开发语言·c++·算法
Monkey的自我迭代2 小时前
python线性回归:从原理到实战应用
开发语言·python·机器学习
德育处主任Pro2 小时前
p5.js 三角形triangle的用法
开发语言·javascript·ecmascript
你我约定有三2 小时前
分布式微服务--RPC:原理、使用方式、与 HTTP/REST 的区别与选择
java·开发语言·分布式·后端·微服务·rpc
孞㐑¥2 小时前
Linux之网络部分-应用层协议 HTTP
linux·开发语言·c++·经验分享·笔记
楼田莉子2 小时前
C++学习之继承
开发语言·c++·学习·visual studio
SchuylerEX3 小时前
第六章 JavaScript 互操(3)JS调用.NET
前端·javascript·c#·.net·blazor