C language identifier requirements:
1. The reserved word;
2. Include only letters, Numbers and underscore (" _ "),
3. Don't begin with Numbers,
Input:
A line, contains a string, the string does not contain any whitespace, and the length is not more than 20,
Output:
A line, if it is the legal identifier of the C language, the output yes, otherwise no output,
The sample input:
RKPEGX9R; TWyYcp
The sample output:
No
I write so
# include & lt; String. H>
# include & lt; Stdio. H>
Int h (char a)
{
If ((a>='a' & amp; & A<='z') | | (a>='A' & amp; & A<='Z') | | (a>='0' & amp; & A<='9'))
{return 1; }
return 0;
}
Int f (char a)
{
If (a>='a' & amp; & A<='z' | | a>='A' & amp; & A<='Z')
{return 1; }
return 0;
}
Int main ()
{
Int I, CNT;
Char sym [20].
Gets (sym);
If ((sym [0]!='_') & amp; & (! F (sym [0])))
{
Puts (" no ");
return 0;
}
For (I=1, CNT=1; Cnt<20; Cnt++)
{
If (h (sym/CNT) | | (sym (CNT)='_'))
{I=1; }
The else
{I=0;
break; }
}
If (I==1)
{puts (" yes "); }
The else
{puts (" no "); }
return 0;
}
But the output is yes
Want to half a day do not know where to write wrong, please guide
CodePudding user response:
Can anyone tell me?CodePudding user response:
this should be no.==CodePudding user response: