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
word = input().strip()
if word == "hello":print("this word is hello!")
else:print("this word is not hello!")
c++
#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;
}