Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
118433 彭士宝 合法的标识符 C++ Accepted 1 MS 280 KB 562 2025-05-01 22:22:27

Tests(10/10):


Code:

#include <iostream> #include <string> using namespace std; bool is_valid_identifier(const string& str) { if (str.empty()) { return false; } if (!isalpha(str[0]) && str[0] != '_') { return false; } for (char c : str) { if (!isalnum(c) && c != '_') { return false; } } return true; } int main() { string input; cin >> input; if (is_valid_identifier(input)) { cout << "yes" << endl; } else { cout << "no" << endl; } return 0; }