Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3670 | 杨洋杰 | 合法的标识符 | C++ | Compile Error | 0 MS | 0 KB | 440 | 2024-06-22 17:14:08 |
#include<iostream> using namespace std; bool islegitimate(string s){ if(s[0]>='0'&&s[0]<='9') return 0; int b=s.size(); for(int i=0;i<b;i++){ if(s[i]>='a'&&s[i]<='z'||s[i]>='A'&&s[i]<='Z'||s[i]>='0'&&s[i]<='9'||s[i]=='_') continue; else return 0; } return 1; } int main(){ string a; cin>>a; if(islegitimate(s)) cout<<"yes"; else cout<<"no"; return 0; }
Main.cc: In function 'bool islegitimate(std::string)': Main.cc:7:21: warning: suggest parentheses around '&&' within '||' [-Wparentheses] if(s[i]>='a'&&s[i]<='z'||s[i]>='A'&&s[i]<='Z'||s[i]>='0'&&s[i]<='9'||s[i]=='_') ^ Main.cc:7:65: warning: suggest parentheses around '&&' within '||' [-Wparentheses] if(s[i]>='a'&&s[i]<='z'||s[i]>='A'&&s[i]<='Z'||s[i]>='0'&&s[i]<='9'||s[i]=='_') ^ Main.cc: In function 'int main()': Main.cc:17:21: error: 's' was not declared in this scope if(islegitimate(s)) cout<<"yes"; ^