| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 21095 | 杨竣周 | 合法 C 标识符 | C++ | Accepted | 100 | 0 MS | 260 KB | 809 | 2021-06-26 16:17:37 |
#include <iostream> #include <string> #include <cassert> using namespace std; bool checkValidIdentifierOfC(string s) { char c = s[0]; // first char if (c>='0' && c<='9') { return false; } for(int i=0; i<s.size(); i++) { c = s[i]; if ((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z') || (c == '_')) { continue; } else { return false; } } return true; } int main() { string strText; cin >> strText; assert(strText.size() <= 20); if (true == checkValidIdentifierOfC(strText)) { cout << "yes" << endl; } else { cout << "no" << endl; } return 0; }