Takahashi san 2
滥用一下职权,写点 C++20 加的好东西。
std::basic_string::end_with
方法,用于检查字符串是否以给定的内容为后缀。“给定的内容”可以是单个 char,C-style 字符串或 std::string。
因此:
string s;
cin >> s;
cout << (s.ends_with("san") ? "Yes" : "No");
滥用一下职权,写点 C++20 加的好东西。
std::basic_string::end_with
方法,用于检查字符串是否以给定的内容为后缀。“给定的内容”可以是单个 char,C-style 字符串或 std::string。
因此:
string s;
cin >> s;
cout << (s.ends_with("san") ? "Yes" : "No");