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");
posted @ 2024-10-07 18:54  MrPython  阅读(6)  评论(0)    收藏  举报  来源