#include stdioh main int a=3b=2c=1; c-=++b; b=a+c; int b=5c=12; c=b2; a-=c;printfddd abc; a+=--c;printfdddn a b c;
The code provided is incomplete and contains syntax errors. Here is the corrected version:
#include <stdio.h>
int main() {
int a = 3, b = 2, c = 1;
c -= ++b;
b *= a + c;
{
int b = 5, c = 12;
c /= b * 2;
a -= c;
printf("%d,%d,%d,", a, b, c);
a += --c;
printf("%d,%d,%d\n", a, b, c);
}
return 0;
}
Explanation:
c -= ++b;-++bincrements the value ofbby 1 and then assigns it toc. So,cbecomes 3 andbbecomes 3.b *= a + c;-a + cevaluates to 6. The value ofbis multiplied by 6, sobbecomes 18.- Inside the inner block,
int b = 5, c = 12;declares and initializes new variablesbandcwith values 5 and 12 respectively. c /= b * 2;-b * 2evaluates to 10. The value ofcis divided by 10, socbecomes 1.a -= c;-cis subtracted froma, soabecomes 2.printf("%d,%d,%d,", a, b, c);prints the values ofa,b, andcwhich are 2, 18, and 1 respectively.a += --c;---cdecrements the value ofcby 1 and then assigns it toa. So,cbecomes 0 andabecomes 2.printf("%d,%d,%d\n", a, b, c);prints the updated values ofa,b, andcwhich are 2, 18, and 0 respectively.
Output: 2,18,1,2,18,
原文地址: http://www.cveoy.top/t/topic/iMrK 著作权归作者所有。请勿转载和采集!