Current location - Health Preservation Learning Network - Healthy weight loss - If a is int data with a value of 3, what is the value of a after the expression a+=a-=a*a is executed? Please pass the program verification.
If a is int data with a value of 3, what is the value of a after the expression a+=a-=a*a is executed? Please pass the program verification.
a=- 12 .

According to the combination and priority order from left to right, calculate a-=a*a first, and the final result of A is a=a-a*a, and A = 3-3 * 3 =-6;

Then calculate a+=-6, because the value of A has changed to -6 at this time, so the calculation process is a=a+(-6)=-6-6=- 12.

Or:

a+= a-= a * a;

The compound assignment expression runs from right to left and can be divided into:

a-= a * a;

a+= a;

The original value of a is 3.

a-= a * a;

be qualified for sth

a = a-a * a = 3-3 * 3 =-6;

Replay

a+= a;

It naturally becomes-12.

Extended data:

The hierarchical relationship among task priority, relative deadline and idle time can be described by linear relationship. For example,

di+ksj=g

Where k is the slope of the linear relationship and g can be regarded as the priority level. For the determined slope k, the smaller the g, the higher the priority. For example, for G 1

Baidu Encyclopedia-Priority