Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
100494 | 刘轻松 | 合法的标识符 | C++ | Accepted | 1 MS | 280 KB | 468 | 2024-12-08 10:23:54 |
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; bool flag = true; //默认满足条件 if(s[0]>='0' && s[0]<='9'){ flag = false; //数字字符开头,不满足条件 } else{ for(int i=0;i<s.size();i++){ if(!(s[i]>='a' && s[i]<='z' || s[i]>='A' && s[i]<='Z' || s[i]>='0' && s[i]<='9' ||s[i]=='_')){ flag = false; } } } if(flag){ cout<<"yes"; } else{ cout<<"no"; } return 0; }