Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
3671 杨洋杰 合法的标识符 C++ Compile Error 0 MS 0 KB 439 2024-06-22 17:14:35

Tests(0/0):


Code:

#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(a) cout<<"yes"; else cout<<"no"; return 0; }


Run Info:

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:24: error: expected ')' before 'cout'
     if(islegitimate(a) cout<<"yes";
                        ^