看不懂题目的真正意思,求助!
DescriptionYour task is to determine whether a string is a valid variable name in C (for simplicity, you do not need to worry about whether a keyword is valid, that is, if the string is "int" or another key word, it is valid )
Input
The first line is the integer n, which indicates how many tests will be performed. Next, each line of the n lines is the string you need to determine.
Output
The output will contain n rows, each row being "Yes" or "No" depending on whether the corresponding string is a valid variable name
Sample input
5
abc
1yyy
hello
World
Yes%
Sample output
Yes
No
Yes
Yes
No
下面是我理解后写的代码,但是不合题意
#include<stdio.h>
#include<string.h>
int main()
{
int n;
scanf("%d",&n);
char s[100];
int i,length,b;
for(i=1;i<=n;i++)
{
scanf("%s",s);
length=strlen(s);
for(int j=0;j<length;j++)
{
if((s[j]>='A'&&s[j]<='Z')||(s[j]>='a'&&s[j]<='z'))
b=1;
else
{
b=0;
break;
}
}
if(b==1)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
#include<string.h>
int main()
{
int n;
scanf("%d",&n);
char s[100];
int i,length,b;
for(i=1;i<=n;i++)
{
scanf("%s",s);
length=strlen(s);
for(int j=0;j<length;j++)
{
if((s[j]>='A'&&s[j]<='Z')||(s[j]>='a'&&s[j]<='z'))
b=1;
else
{
b=0;
break;
}
}
if(b==1)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}