-
In fact, it is much easier to read by adding parentheses to the first part of your formula! They are the same!
k=(x++>=0)&&y--<=0)||z=x+y) here the first = sign, && and ||Divide the whole equation into four pieces, &&& and ||, according to the priority of the operatorsThe operation level is the same as the order from left to right, and the && operator will be executed when the operation formula on the left is true (=1), so the operation on the right will be executed, so the operation of x++>=0 is -1 after running>=0 is false, so the sentence y--<=0 is not executed, but z=x+y=0+5=5, and finally z=0||1=1
k, x, y, z are 1, 0, 5, 5, respectively
-
The answer in the book is not wrong, I ran it, and the result is also 1,0,5,5 There is a misunderstanding that the boolean value of z=x+y is not 0, but 1, and the boolean value of all assignment statements is, because &&& is better than ||'s priority. So k is equal to 1
I tested it with a program and found that x++>=0 first determine whether x is greater than 0, and then ++.
I can only explain it here, and I don't quite understand why for the rest of it.
You can use the program to see why y=5,z=5
-
Why do you have to ask two questions for one question?
The answer is given, in:
-
For this kind of problem, from the syntactic analysis alone, the program execution will be different, char **pstr; is defined as a secondary pointer of type char; The assignment is conditional on the same type, or the types can be automatically converted between them.
Yes. 1) *pstr, which dissolves the first-level pointer with *, so *pstr is a pointer to the char type. i.e. there is *pstr type which is char*, and ,"hi"Its type is char and it can be converted to char *, which can be assigned.
Same as char *p, a[5]; p=a; Grammatically it is correct.
2) pstr is a secondary pointer, and its type is char **hi"Its type is char and it can be converted to char *, but obviously char ** and char* cannot be converted to each other, so it is actually wrong.
3) **pstr, which dissolves the pointer with **, it is of type char, and 2) in the same way, char and char or char * are obviously not convertible to each other, so they are actually wrong.
-
printf("%d",x-
;Here is the value of the expression that outputs x--, but here because it is a self-decreasing expression, and x is on the left, the value of the expression is still the value of x, so the output statement is executed, and the output result is 3, and then executed.
while(!x);Because this is the inverse, the result is 0, that is, false, so the program is executed, of course, the premise is that you ubt
x=3;This should be the int type, right?
2. 1, True 2, False (there is only one program) 3, False (not necessarily) 4, True. >>>More
Definition of a for loop.
for(the initial value of the variable; termination of operating conditions; The initial value of the first cycle i is 0, and it runs until i=3 stops i=2, and the condition is still satisfied, and the loop body is still executed, and the step size is 1+1 each time >>>More
I thought about it for a long time and didn't come up with it. >>>More
main() [main function main program].
int i,j,k;【Define integer data i,j,k】for(i=1; i<=6;i++) main loop, i from 1 to 6, increasing to 1] for(j=1; j<=20-2*i;j++) subcycle, j from 1 to 20-2*i >>>More
I want to write it to you! It's a pity that I'm off work, hehe.