杭电acm2024

http://acm.hdu.edu.cn/showproblem.php?pid=2024

在C语言程序设计中程序中使用的变量名、函数名、标号等统称为标识符。除库函数的函数名由系统定义外其余都由用户自定义。C规定标识符只能是字母(AZaz)、数字(09)、下划线(_)组成的字符串并且其第一个字符必须是字母或下划线。

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 }
原文地址:https://www.cnblogs.com/huzhenbo113/p/2983242.html