❶ c璇璦 杈撳叆涓涓瀛楃︿覆錛屽垽鏂鍏舵槸鍚︽槸C鐨勫悎娉曟爣璇嗙︺
1銆佷嬌鐢ㄤ腑鏂囧綋鏍囪瘑絎︼紝鍏跺墠鎻愭槸緙栬瘧鍣ㄦ敮鎸佷腑鏂囧綋鏍囪瘑絎︼紝C++11涔嬪悗錛岄氱敤瀛楃﹀悕瑕嗙洊鍒頒簡奼夊瓧銆
2銆佷嬌鐢ㄤ腑鏂囦綔涓烘爣璇嗙︽椂錛屽叾澶存枃浠朵笌鍘熸潵涓鏍楓
3銆佺▼搴忎腑鐨勫悕瀛楃┖闂達紝淇濇寔涓嶅彉銆
4銆佸彲浠ュ皢淇濈暀瀛楀畾涔変負涓鏂囷紝鐢╠efine瀹氫箟銆
5銆佸彲浠ョ敤綾誨瀷鍚嶏紝鐩存帴瀹氫箟涓鏂囩殑鍙橀噺鍚嶃
6銆佷腑鏂囨爣璇嗙︾殑浣跨敤錛屽拰鏅閫氭爣璇嗙︿竴鏍楓
❷ 杈撳叆涓涓瀛楃︿覆錛屽垽鏂鍏舵槸鍚︽槸C鐨勫悎娉曟爣璇嗙︺傜敤c璇璦緙栧啓紼嬪簭銆
C璇璦鍚堟硶鏍囪瘑絎鐢辨暟瀛楋紝瀛楁瘝錛涓嬪垝綰緇勬垚銆
涓旂涓涓瀛楁瘝涓嶈兘涓烘暟瀛椼
浜庢槸錛屾牴鎹鍏跺畾涔夛紝鍙浠ヨ繘琛屽垽鏂錛屼唬鐮佸備笅錛
#defineis_upper(x)(x>='A'&&x<='Z')//澶у啓瀛楁瘝鍒ゆ柇銆
#defineis_lower(x)(x>='a'&&x<='z')//灝忓啓瀛楁瘝鍒ゆ柇銆
#defineis_char(x)(is_upper(x)||is_lower(x))//瀛楁瘝鍒ゆ柇銆
#defineis_num(x)(x>='0'&&x<='9')//鏁板瓧鍒ゆ柇銆
#defineis_down_link(x)(x=='_')//涓嬪垝綰垮垽鏂銆
intcheck_first_char(charx)//鍒ゆ柇絎涓涓瀛楃︽槸鍚﹀悎娉曘
{
returnis_char(x)||is_down_link(x);//褰撲負瀛楁瘝鎴栦笅鍒掔嚎鏃跺悎娉曘
}
intcheck_other_char(charx)//鍒ゆ柇鍏跺畠瀛楃︽槸鍚﹀悎娉曘
{
returnis_char(x)||is_down_link(x)||is_num(x);//褰撲負鏁板瓧錛屽瓧姣嶆垨涓嬪垝綰挎椂鍚堟硶銆
}
intcheck(char*str)//鍒ゆ柇鏍囪瘑絎str鏄鍚﹀悎娉曪紝濡傛灉鍚堟硶榪斿洖1錛屽惁鍒欒繑鍥炲亣銆
{
inti;
if(check_first_char(str[0])==0)return0;//媯鏌ョ涓瀛楃︺
for(i=1;str[i];i++)
if(check_other_char(str[i])==0)return0;//媯鏌ュ叾瀹冨瓧絎︺
return1;
}
intmain()
{
charid[200];
scanf("%s",id);//璇誨叆鏍囪瘑絎︺
if(check(id))//榪涜屽垽鏂騫惰緭鍑虹粨鏋溿
printf("鏍囪瘑絎﹀悎娉昞n");
elseprintf("鏍囪瘑絎﹂潪娉昞n");
}