Run ID:118433
提交时间:2025-05-01 22:22:27
#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; }