1 条题解
-
0
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; }Java :
import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner sc = new Scanner(System.in); String str = sc.nextLine(); if(str.contains(" ")||str.equals("int")||str.equals("double")||str.equals("cout")||str.equals("cin")||str.contains("#")||str.startsWith("0")||str.startsWith("1")||str.startsWith("2")||str.startsWith("3")||str.startsWith("4")||str.startsWith("5")||str.startsWith("6")||str.startsWith("7")||str.startsWith("8")||str.startsWith("9")){ System.out.println("no"); }else{ System.out.println("yes"); } } }
- 1
信息
- ID
- 388
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者