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;
}
    
相关推荐
张人玉2 小时前
如何使用Advanced Installer打包C#程序生成安装程序
c#·打包·advanced·installer
葛小白13 小时前
C#数据类型:string简单使用
服务器·数据库·c#
杯莫停丶4 小时前
设计模式之:模板模式
开发语言·设计模式
开发者小天4 小时前
调整为 dart-sass 支持的语法,将深度选择器/deep/调整为::v-deep
开发语言·前端·javascript·vue.js·uni-app·sass·1024程序员节
老猿讲编程5 小时前
C++中的奇异递归模板模式CRTP
开发语言·c++
汤姆yu8 小时前
基于python的化妆品销售分析系统
开发语言·python·化妆品销售分析
ScilogyHunter8 小时前
C语言标准库完全指南
c语言·开发语言
sali-tec8 小时前
C# 基于halcon的视觉工作流-章52-生成标定板
开发语言·图像处理·人工智能·算法·计算机视觉
应茶茶8 小时前
C++11 核心新特性:从语法重构到工程化实践
java·开发语言·c++
程子的小段8 小时前
C 语言实例 - 字符串复制
c语言·开发语言