fork download
  1. #include <stdio.h>
  2.  
  3. int x;
  4. void mondai1(int b){
  5. x = b;
  6. }
  7.  
  8. void mondai2(void){
  9. static int c = 10;
  10. x = c;
  11. c++;
  12. }
  13.  
  14. int mondai3(int d){
  15. x++;
  16. d++;
  17. return d;
  18. }
  19.  
  20. int main(void){
  21. printf("x = %d[GS:return0で0を呼び戻したから]\n", x);
  22. x = 101;
  23. printf("x = %d[GS:上でx=101を代入しているから]\n", x);
  24.  
  25. mondai1(102);
  26. printf("x = %d[GS:mondai1(102)はx=102のときに実行されるから]\n", x);
  27.  
  28. mondai2();
  29. mondai2();
  30. mondai2();
  31. printf("x = %d[GS:mondai2のプログラムで3回実行されてc=10+1+1になるから]\n", x);
  32.  
  33. for (int i = 103; i < 104; i++){
  34. int x = i;
  35. printf("x = %d[LA:x=103が上で代入されているから]\n", x);
  36. x = mondai3(i);
  37. printf("x = %d[LA:x=103+1をした値だから]\n", x);
  38. }
  39.  
  40. printf("x = %d[GS:mondai3という関数に戻ってx=x+1されているから]\n", x);
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
x = 0[GS:return0で0を呼び戻したから]
x = 101[GS:上でx=101を代入しているから]
x = 102[GS:mondai1(102)はx=102のときに実行されるから]
x = 12[GS:mondai2のプログラムで3回実行されてc=10+1+1になるから]
x = 103[LA:x=103が上で代入されているから]
x = 104[LA:x=103+1をした値だから]
x = 13[GS:mondai3という関数に戻ってx=x+1されているから]