http://acm.hdu.edu.cn/showproblem.php?pid=2024
在C語言程式設計中程式中使用的變量名、函數名、标号等統稱為辨別符。除庫函數的函數名由系統定義外其餘都由使用者自定義。C規定辨別符隻能是字母(AZaz)、數字(09)、下劃線(_)組成的字元串并且其第一個字元必須是字母或下劃線。

View Code
1 #include<stdio.h>
2 #include<string.h>
3 int pro(char *s)
4 {
5 int i,flag=0;
6 if((s[0]<\'A\'||(s[0]>\'Z\'&&s[0]<\'a\')||s[0]>\'z\')&&s[0]!=\'_\')
7 return 0;
8 for(i=1;s[i]!=\'\0\';i++)
9 if((s[i]<\'A\'||(s[i]>\'Z\'&&s[i]<\'a\')||s[i]>\'z\')&&s[i]!=\'_\'&&(s[i]>\'9\'||s[i]<\'0\'))
10 return 0;
11 return 1;
12 }
13 int main()
14 {
15 char s[10000];
16 int i,n;
17 scanf("%d",&n);
18 gets(s);
19 while(n--)
20 {
21 gets(s);
22 if(pro(s))
23 printf("yes\n");
24 else printf("no\n");
25 }
26 return 0;
27 }