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;
}
    
相关推荐
期待のcode30 分钟前
原子操作类LongAdder
java·开发语言
A_nanda1 小时前
c# MOdbus rto读写串口,如何不相互影响
算法·c#·多线程
lly2024061 小时前
C 语言中的结构体
开发语言
JAVA+C语言2 小时前
如何优化 Java 多主机通信的性能?
java·开发语言·php
青岑CTF3 小时前
攻防世界-Ics-05-胎教版wp
开发语言·安全·web安全·网络安全·php
Li emily3 小时前
如何通过外汇API平台快速实现实时数据接入?
开发语言·python·api·fastapi·美股
码云数智-园园3 小时前
使用 C# 将 PowerPoint 演示文稿高效转换为 PDF 格式
c#
APIshop4 小时前
Java 实战:调用 item_search_tmall 按关键词搜索天猫商品
java·开发语言·数据库
血小板要健康4 小时前
Java基础常见面试题复习合集1
java·开发语言·经验分享·笔记·面试·学习方法
淼淼7634 小时前
安装jdk1.8
java·开发语言