Home > Back-end >  Campus oj topic question
Campus oj topic question

Time:12-13

C language beginner, why can't I write output?

CodePudding user response:

To this:
 while ((ch=getchar ())!='\ n') 


If you use the
 while (ch=getchar ()!='\ n') 

This ch is true or false

CodePudding user response:

Input is a string, not a single character, modified as follows, for reference:
 # include & lt; stdio.h> 
Int main (int arg c, char * argv [])
{
Int vowel (char ch);
Int x, sum=0, I=0;
Char ch [80].
Gets (ch);
While (ch [I]!='\ 0') {
If (vowel (ch) [I])
The sum +=1;
i++;
}
Printf (" % d ", sum);
system("pause");
return 0;
}

Int vowel (char ch)
{
If (ch=='A' | | ch=='A' | | ch=='E' | | ch=='E' | | ch=='I' | | ch=='I' | | ch=='o' | | ch=='o')
return 1;
return 0;
}

CodePudding user response:

While (ch=getchar ()! )
='\ n'
The following instead, give it a try:

reference
while ((ch=getchar ())!='\ n')

CodePudding user response:

This screen carbon baked?

CodePudding user response:

The
reference 1/f, confident boy reply:
change to this:
 while ((ch=getchar ())!='\ n') 


If you use the
 while (ch=getchar ()!='\ n') 

Ch is so true and false
thank you

CodePudding user response:

refer to the second floor QZJHJXJ response:
input string, not a single character, modified as follows, for reference:
 # include & lt; stdio.h> 
Int main (int arg c, char * argv [])
{
Int vowel (char ch);
Int x, sum=0, I=0;
Char ch [80].
Gets (ch);
While (ch [I]!='\ 0') {
If (vowel (ch) [I])
The sum +=1;
i++;
}
Printf (" % d ", sum);
system("pause");
return 0;
}

Int vowel (char ch)
{
If (ch=='A' | | ch=='A' | | ch=='E' | | ch=='E' | | ch=='I' | | ch=='I' | | ch=='o' | | ch=='o')
return 1;
return 0;
}
thank you

CodePudding user response:

The
reference 3 floor ctrigger response:
while (ch=getchar ()! )
='\ n'
The following instead, give it a try:

reference
while ((ch=getchar ())!='\ n')
thank you
  • Related