1 条题解

  • 0
    @ 2023-3-13 11:09:41

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
    	string s;
    	//读入字符串 
    	getline(cin,s);
    	bool r = true;
    	
    	int i;
    	//循环看有没有字母、数字、下划线以外的字符
    	for(i = 0;i < s.size();i++){
    		//含有非法字符 
    		if((isalpha(s[i]) || isdigit(s[i]) || s[i] == '_') == false){
    			r = false;
    			break;
    		}
    	} 
    	
    	//判断不能以数字开头
    	if(isdigit(s[0])){
    		r = false;
    	} 
    	
    	//判断不是四个特殊含义的单词
    	if(s == "int" || s == "double" || s == "cout" || s == "cin") {
    		r = false;
    	}
    	
    	if(r == true){
    		cout<<"yes"<<endl;
    	}else{
    		cout<<"no"<<endl;
    	} 
    	
    	
        return 0;
    }
    
    
    • 1

    信息

    ID
    1664
    时间
    1000ms
    内存
    16MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者