Home > Back-end >  The operation result why is wrong
The operation result why is wrong

Time:04-23

# include
Void main ()
{
Int a=0, b=0, c=0, d=0;
Char x;
while(x! )
='\ n'{
X=getchar ();
If ((x<='z' & amp; & X>='a') | | (' a '& lt;=x& & X<='Z'))
+;
Else if (x>='0' & amp; & X<='9')
B++;
Else if (x==' ')
c++;
The else
d++;
}
Printf (" a=% d, b=% d, c=% d, e=% d \ n ", & amp; A, & amp; B, & amp; C., & amp; D);
}


CodePudding user response:

Code function at the end of the day is not others to help you see or interpretation or comment; But by myself calm down and take a long enough time and energy to do it yourself step or set a breakpoint or step to perform to a certain intermediate result shows or written to the log file analysis step by step,
Remind: cow x teacher cannot replace the student understand and use the toilet!
Single step debugging and set breakpoint debugging (VS IDE compilation connection through later, press F10 or F11 key step, press Shift + F11 exit the current function; In a press F9 set breakpoints after press F5 execution stops at the breakpoint,) is one of the programmers must master the skills,

CodePudding user response:

 # include 
//void main ()
Int main ()
{
Int a=0, b=0, c=0, d=0;
Char x=0;
while(x! )
='\ n'{
X=getchar ();
If ((x<='z' & amp; & X>='a') | | (' a '& lt;=x& & X<='Z'))
+;
Else if (x>='0' & amp; & X<='9')
B++;
Else if (x==' ')
c++;
The else
d++;
}
//printf (" a=% d, b=% d, c=% d, e=% d \ n ", & amp; A, & amp; B, & amp; C., & amp; D);
Printf (" a=% d, b=% d, c=% d, e=% d \ n ", a, b, c, d);
}


For your reference ~

CodePudding user response:

Why to define x=0?

CodePudding user response:

The
reference 3 floor weixin_56874565 response:
why define x=0?

Initialization, otherwise is a random value, if it is a random value for '\ n' wouldn't it be a also does not perform,
  • Related