fork download
  1. #include <stdio.h>
  2. int x;
  3. void mondai1(int b){
  4. x=b;
  5. }
  6. void mondai2(void){
  7. static int c=10;
  8. x=c;
  9. c++;
  10. }
  11. int mondai3(int d){
  12. x++;
  13. d++;
  14. return d;
  15. }
  16. int main(void) {
  17. printf("x=%d [GS:グローバル変数は0で初期化される]\n",x);
  18. x=101;
  19. printf("x=%d [GS:前行でxに101を代入した]\n",x);
  20. mondai1(102);
  21. printf("x=%d [GS:mondai1(102)を呼び出し、xに102を代入した]\n",x);
  22. mondai2();
  23. mondai2();
  24. mondai2();
  25. printf("x=%d [GS:mondai2()を3回呼び出し、10→11→12の順でxに代入した]\n",x);
  26. for(int i=103;i<104;i++){
  27. int x=i;
  28. printf("x=%d [LA:for文の中でx=iと定義し、103を代入した]\n",x);
  29. x=mondai3(i);
  30. printf("x=%d [LA:mondai3を呼び出し、103に1を足して代入した]\n",x);
  31. }
  32. printf("x=%d [GS:mondai3を呼び出したとき12行目でxを++した]\n",x);
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
x=0 [GS:グローバル変数は0で初期化される]
x=101 [GS:前行でxに101を代入した]
x=102 [GS:mondai1(102)を呼び出し、xに102を代入した]
x=12 [GS:mondai2()を3回呼び出し、10→11→12の順でxに代入した]
x=103 [LA:for文の中でx=iと定義し、103を代入した]
x=104 [LA:mondai3を呼び出し、103に1を足して代入した]
x=13 [GS:mondai3を呼び出したとき12行目でxを++した]