-
The analysis is as follows.
The first cycle.
y=1. y=((x=3*y,x+1),x-1);
This sentence is syntactic.
First of all, it is clear that the assignment sign "=" takes precedence over the comma expression operator "no", and the comma expression takes the value of the rightmost expression.
x=3*y), x+1 This expression first calculates x=3*1=3, and the value of the comma expression is the value of x+1 on the far right, which is 4 (note that the value of x is 3).
y=(4,x-1);The comma expression in () to the right of this expression is 2 if the value is x-1
So y = 2
the second loop (actually x+1 is a distractor, because the comma expression has a point x+1 that doesn't actually work, y=((x=3*y,x+1),x-1); It can be simplified to y=((x=3*y),x-1).
y=2 is similar to the same analysis.
x=3*2= 6
y=(7,x-1)
y=5 The third cycle is directly analyzed with the simplified y=5x=3*5=15
y=14 does not satisfy y<10 cycle ends.
The output x is 15 and the y is 14
The above analysis is OK with C-free running and actual measurement
-
#include
#include
void fun (char*p) receives the first address of the str array}main().
islower() determines whether it is a lowercase letter, if it is true, otherwise it is false p[i-1]=p[i-1]-'a'+'a'Such as:'b'='b'-'a'+'a'=1+'a'='b'
Hope it helps.
-
1 Hello all, a++ and ++a are auto-increment operations, which are equivalent to a=a+1;a--and --a are self-subtracting operations, which are equivalent to a=a-1
+a" or "--a" is to increase and decrease first and then participate in the calculation; "A++" or "A--" is to participate in the calculation first and then increase and decrease.
Therefore, your question c = 6 * 6 * 6 = 216 (A does not increase to 7 until the statement is executed).
-
c=6*6*6;
+a" or "--a" is to increase and decrease first and then participate in the calculation;
a++" or "a--" is to participate in the calculation first and then self-increase and self-subtract to remember a sentence, + in the front of the encounter, even if ++ in the back, you can ignore it, and wait for the end of the current statement to carry out the self-increment operation.
-
In the first question, a,p points to the first address of the s array, that is, p points to s[0], p->y=s, so s[0]->y also points to s[0], this sentence is useless. The output statement ++p->x, -> priority is greater than ++, so it is ++ (p->x), p->x is 1, add it first, become 2, and output 2
In the second question, b,p points to s[1], p->y points to s[0], where p->x is equivalent to s[1].x, is 2; After p=p->y, p points to s[0], where p->x is equivalent to s[0].x, is 1; 2 1 should be output at the end
-
To do this kind of problem, you need to break down the expression to understand it.
j=(i++)i++)i);
Translated into a single statement, it is:
i++;in the first parentheses.
i++;in the second parentheses.
i;in the third parentheses.
The above is the first group.
i;The first ()+
i;The second ()+
The upper two are the second group.
Depending on the compiler, there will be different results, but if you look at your values, it belongs to the following operations.
The first set is executed with (3) +3) +4), and the compiler does not perform the operation in a left-to-right priority. If it is a traditional C C++ operation rule, it should be (3) + (4) + (6).
After the second set is performed, j = 10. If it is a traditional C++ operation rule, it should be j = 13.
Now let's talk about the i-value:
i performed the i = i + 1 operation three times, so: i, the final result, i = 6.
In this regard, the rules of C are more obvious.
Step 1: j = (3++)i++)i);
Step 2: j = 3 + 4++)i);
Step 3: j = 3 + 4 + 5);
Step 4: j = 3 + 4 + 6;
Step 5: j = 7 + 6;
Step 6: j = 13.
The priority of the operation is parenthesis first, and then the operation is calculated from left to right.
-
Read the book on your own.
i++, which is to use the value of i first, and then add itself.
i, is to add 1 first, and then use the value for other operations %d, integer output.
Read more books by yourself, this is not difficult to understand.
-
Brother! You play with me! I ran it in the program and the first result was i=6, j=9!! I said how to do it wrong!
i++ is to calculate i first and then +1, the first formula should be j=3+3+3=9, that is to say, only i=3, and finally + well, of course, it is i+1+1+1=6
-
It seems that this value is not the same for different compilers.
-
The prefix is added first and then assigned, and the suffix is assigned first and then added, so i++ is always 3, but ++i is 4So j is 3+3+4=10
At this point, the value of i has been assigned as 6, 3 plus 1 plus 1 plus 1
You can look at the difference between the prefix and the suffix of the auto-increment operator.
-
2+4+1=7 so this input you are at least 7 bits, if less than 7 bits will not produce results, so the input x,y is only two %d is %2d means x=12, %d means y=7, so the result is 19,.
-
I'd also like to know what %*4c means.
-
Let's break it down:
1) Pass 0 and 1234 to the fun function first, because s2 > 10, the function is executed down, s1=4, and then pass s1 and s2 10 (123) to again.
fun function.
2) Since s2 10(123) is s2 in the s2<10 judgment in the second pass, he still cannot meet the condition, and the function is executed downward. Since s1=s1*10+s2%10; s1 becomes 43, and s2 10 is to pass 123 10=12, and pass 43 and 12 to fun again
3) 12 still can't meet the condition of if, according to the above rules, s1 becomes 43*10+12%10 is 432, and s2 becomes 1
4) S2 becomes 1 to satisfy the if condition, and the function returns the value of S1*10+S2%10, where S1 passes 432 and S2 is 1, and 4321
-
In the function iteration process, the last s1 is increased by one digit (multiplied by 10) and then added to the single digit of this s2 (s2%10), and when s2 is already a single digit, the iteration starts to return.
-
This is a recursion, and it's easy to see that just looking at the fun function, its function is to add the s2 flashback after s1, so the question is a 4321
-
This is obviously a sorting problem, after the comparison of si and s2, take the big one, so the first to get is 4, in turn is 3, 2, 1 and so sorted, c language textbook on the classic bubble sorting method, you can take a look wow! Remember to pick me.
Choose B1, hundreds of students means hundreds of students, is an approximation, this question is about the same as about, so do not choose A >>>More
The result of running on vc++2005 is 002222
This kind of thing will get different values in different systems, garbage questions, don't bother. >>>More
Cite month[12][10]; Wrong. Without the element month[12][10], up to month[11][9], and the pointer p is useless. There's also the deletion of all your +10-level corresponding *. >>>More
First, the basic interpretation of the word Jin:
2. Saliva; Khan: Fluid. All over the body. >>>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