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;
}
    
相关推荐
阿贵---25 分钟前
C++中的RAII技术深入
开发语言·c++·算法
Traced back31 分钟前
怎么用 Modbus 让两个设备互相通信**,包含硬件接线、协议原理、读写步骤,以及 C# 实操示例。
开发语言·c#
一个帅气昵称啊1 小时前
基于.NET AgentFramework开发OpenClaw智能体框架
人工智能·自然语言处理·c#·.net·openclaw
娇娇yyyyyy2 小时前
QT编程(17): Qt 实现自定义列表模型
开发语言·qt
唐青枫2 小时前
C#.NET SpinLock 深入解析:自旋锁原理、使用边界与性能取舍
c#·.net
ms_27_data_develop2 小时前
Java枚举类、异常、常用类
java·开发语言
add45a2 小时前
C++编译期数据结构
开发语言·c++·算法
岁岁种桃花儿3 小时前
AI超级智能开发系列从入门到上天第四篇:AI应用方案设计
java·服务器·开发语言
Amnesia0_03 小时前
C++中的IO流
开发语言·c++