fork download
  1. #include <stdio.h>
  2. /*
  3.   代入演算子を用いた計算
  4. */
  5. int main(int argc, char** argv){
  6. /* 使用する変数の定義 */
  7. int a1=2,b1=2,c1=2,d1=2; // 変数の宣言(1)
  8. int a2=2,b2=2,c2=2,d2=2; // 変数の宣言(2)
  9. //  普通の演算による計算と代入
  10. a1 = a1 + 1;
  11. b1 = b1 - 1;
  12. c1 = c1 * 2;
  13. d1 = d1 / 2;
  14. // 代入演算による計算
  15. a2 += 1;
  16. b2 -= 1;
  17. c2 *= 2;
  18. d2 /= 2;
  19. printf("a1=%d b1=%d c1=%d d1=%d\n",a1,b1,c1,d1);
  20. printf("a2=%d b2=%d c2=%d d2=%d\n",a2,b2,c2,d2);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
a1=3 b1=1 c1=4 d1=1
a2=3 b2=1 c2=4 d2=1