❶ 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");
}