fork download
  1. intgra[4][4];
  2.  
  3. int*ptr=&gra;
  4.  
  5. intx=3,y=3;
  6.  
  7. typedefenum{CMD_NONE=0,
  8. CMD_SHUFFLE,
  9. CMD_UP=8,
  10. CMD_DOWN=2,
  11. CMD_LEFT=4,
  12. CMD_RIGHT=6,
  13. CMD_QUIT}Cmd;
  14.  
  15. voidinit()
  16. {
  17. inti,j,k;
  18. for(i=0;i<15;)
  19. {
  20. k=0;
  21. intn=rand()%15+1;
  22. for(j=0;j<i;j++)
  23. if(*(ptr+j)==n)
  24. k=1;
  25. if(k==0)
  26. {
  27. *(ptr+i)=n;
  28. i++;
  29. }
  30. }
  31. }
  32.  
  33. voidswapIndexes(intx1,inty1,intx2,inty2)
  34. {
  35. ukladanka[x1][y1]=ukladanka[x2][y2];
  36. ukladanka[x2][y2]=0;
  37. x=x2;y=y2;
  38. }
  39.  
  40. voidmove(Cmddir)
  41. {
  42. if(x==3&&dir==CMD_LEFT)
  43. return;
  44. if(x==0&&dir==CMD_RIGHT)
  45. return;
  46. if(y==0&&dir==CMD_DOWN)
  47. return;
  48. if(y==3&&dir==CMD_UP)
  49. return;
  50. switch(dir){
  51. caseCMD_LEFT:
  52. swapIndexes(x,y,x+1,y);
  53. break;
  54. caseCMD_RIGHT:
  55. swapIndexes(x,y,x-1,y);
  56. break;
  57. caseCMD_DOWN:
  58. swapIndexes(x,y,x,y-1);
  59. break;
  60. caseCMD_UP:
  61. swapIndexes(x,y,x,y+1);
  62. break;
  63. }
  64. }
  65.  
  66. voiddisplay()
  67. {
  68. system("cls");
  69. inti,j,k;
  70. for(i=0;i<4;i++)
  71. {
  72. for(k=0;k<4;k++)
  73. {
  74. if(ukladanka[k][i])
  75. printf("\xda\xc4\xc4\xc4\xc4\xbf");
  76. else
  77. printf("");
  78. }
  79. printf("\r\n");
  80. for(j=0;j<4;j++)
  81. {
  82. if(ukladanka[j][i])
  83. printf("\xb3%2d\xb3",ukladanka[j][i]);
  84. else
  85. printf("");
  86. }
  87. printf("\r\n");
  88. for(k=0;k<4;k++)
  89. {
  90. if(ukladanka[k][i])
  91. printf("\xc0\xc4\xc4\xc4\xc4\xd9");
  92. else
  93. printf("");
  94. }
  95. printf("\r\n");
  96. }
  97. }
  98.  
  99. voidcheckForWin()
  100. {
  101.  
  102. }
  103.  
  104. intkbhandle()
  105. {
  106.  
  107. intch=getch();
  108. if(ch==224||ch==0)
  109. {
  110. ch=getch();
  111. switch(ch){
  112. case72:
  113. returnCMD_UP;
  114. case80:
  115. returnCMD_DOWN;
  116. case75:
  117. returnCMD_LEFT;
  118. case77:
  119. returnCMD_RIGHT;
  120. default:
  121. returnCMD_NONE;
  122. }
  123. }
  124. if(ch==113)
  125. returnCMD_QUIT;
  126. if(ch==110)
  127. returnCMD_SHUFFLE;
  128. returnCMD_NONE;
  129. }
  130.  
  131. {
  132. init();
  133. display();
  134. while(1)
  135. {
  136. Cmdc=kbhandle();
  137. if(c==CMD_QUIT)
  138. {
  139. printf("\r\nBye!\r\n");
  140. return(0);
  141. }
  142. if(c==CMD_SHUFFLE)
  143. init();
  144. elseif(c!=CMD_NONE)
  145. move(c);
  146. display();
  147. checkForWin();
  148. }
  149. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:1: warning: data definition has no type or storage class
 intgra[4][4];
 ^
prog.c:1:1: warning: type defaults to 'int' in declaration of 'intgra' [-Wimplicit-int]
prog.c:3:10: error: 'gra' undeclared here (not in a function)
 int*ptr=&gra;
          ^
prog.c:5:1: warning: data definition has no type or storage class
 intx=3,y=3;
 ^
prog.c:5:1: warning: type defaults to 'int' in declaration of 'intx' [-Wimplicit-int]
prog.c:5:8: warning: type defaults to 'int' in declaration of 'y' [-Wimplicit-int]
 intx=3,y=3;
        ^
prog.c:7:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 typedefenum{CMD_NONE=0,
            ^
prog.c:13:10: warning: data definition has no type or storage class
 CMD_QUIT}Cmd;
          ^
prog.c:13:10: warning: type defaults to 'int' in declaration of 'Cmd' [-Wimplicit-int]
prog.c:15:1: warning: return type defaults to 'int' [-Wimplicit-int]
 voidinit()
 ^
prog.c: In function 'voidinit':
prog.c:17:1: error: 'inti' undeclared (first use in this function)
 inti,j,k;
 ^
prog.c:17:1: note: each undeclared identifier is reported only once for each function it appears in
prog.c:17:6: error: 'j' undeclared (first use in this function)
 inti,j,k;
      ^
prog.c:17:5: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 inti,j,k;
     ^
prog.c:17:8: error: 'k' undeclared (first use in this function)
 inti,j,k;
        ^
prog.c:17:7: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 inti,j,k;
       ^
prog.c:18:5: error: 'i' undeclared (first use in this function)
 for(i=0;i<15;)
     ^
prog.c:21:1: error: 'intn' undeclared (first use in this function)
 intn=rand()%15+1;
 ^
prog.c:21:6: warning: implicit declaration of function 'rand' [-Wimplicit-function-declaration]
 intn=rand()%15+1;
      ^
prog.c:23:14: error: 'n' undeclared (first use in this function)
 if(*(ptr+j)==n)
              ^
prog.c: At top level:
prog.c:33:1: warning: return type defaults to 'int' [-Wimplicit-int]
 voidswapIndexes(intx1,inty1,intx2,inty2)
 ^
prog.c: In function 'voidswapIndexes':
prog.c:33:1: warning: type of 'intx1' defaults to 'int' [-Wimplicit-int]
prog.c:33:1: warning: type of 'inty1' defaults to 'int' [-Wimplicit-int]
prog.c:33:1: warning: type of 'intx2' defaults to 'int' [-Wimplicit-int]
prog.c:33:1: warning: type of 'inty2' defaults to 'int' [-Wimplicit-int]
prog.c:35:1: error: 'ukladanka' undeclared (first use in this function)
 ukladanka[x1][y1]=ukladanka[x2][y2];
 ^
prog.c:35:11: error: 'x1' undeclared (first use in this function)
 ukladanka[x1][y1]=ukladanka[x2][y2];
           ^
prog.c:35:15: error: 'y1' undeclared (first use in this function)
 ukladanka[x1][y1]=ukladanka[x2][y2];
               ^
prog.c:35:29: error: 'x2' undeclared (first use in this function)
 ukladanka[x1][y1]=ukladanka[x2][y2];
                             ^
prog.c:35:33: error: 'y2' undeclared (first use in this function)
 ukladanka[x1][y1]=ukladanka[x2][y2];
                                 ^
prog.c:37:1: error: 'x' undeclared (first use in this function)
 x=x2;y=y2;
 ^
prog.c: At top level:
prog.c:40:1: warning: return type defaults to 'int' [-Wimplicit-int]
 voidmove(Cmddir)
 ^
prog.c: In function 'voidmove':
prog.c:40:1: warning: type of 'Cmddir' defaults to 'int' [-Wimplicit-int]
prog.c:42:4: error: 'x' undeclared (first use in this function)
 if(x==3&&dir==CMD_LEFT)
    ^
prog.c:42:10: error: 'dir' undeclared (first use in this function)
 if(x==3&&dir==CMD_LEFT)
          ^
prog.c:42:15: error: 'CMD_LEFT' undeclared (first use in this function)
 if(x==3&&dir==CMD_LEFT)
               ^
prog.c:43:1: warning: 'return' with no value, in function returning non-void
 return;
 ^
prog.c:44:15: error: 'CMD_RIGHT' undeclared (first use in this function)
 if(x==0&&dir==CMD_RIGHT)
               ^
prog.c:45:1: warning: 'return' with no value, in function returning non-void
 return;
 ^
prog.c:46:15: error: 'CMD_DOWN' undeclared (first use in this function)
 if(y==0&&dir==CMD_DOWN)
               ^
prog.c:47:1: warning: 'return' with no value, in function returning non-void
 return;
 ^
prog.c:48:15: error: 'CMD_UP' undeclared (first use in this function)
 if(y==3&&dir==CMD_UP)
               ^
prog.c:49:1: warning: 'return' with no value, in function returning non-void
 return;
 ^
prog.c:52:1: warning: implicit declaration of function 'swapIndexes' [-Wimplicit-function-declaration]
 swapIndexes(x,y,x+1,y);
 ^
prog.c:60:1: warning: label 'caseCMD_UP' defined but not used [-Wunused-label]
 caseCMD_UP:
 ^
prog.c:57:1: warning: label 'caseCMD_DOWN' defined but not used [-Wunused-label]
 caseCMD_DOWN:
 ^
prog.c:54:1: warning: label 'caseCMD_RIGHT' defined but not used [-Wunused-label]
 caseCMD_RIGHT:
 ^
prog.c:51:1: warning: label 'caseCMD_LEFT' defined but not used [-Wunused-label]
 caseCMD_LEFT:
 ^
prog.c: At top level:
prog.c:66:1: warning: return type defaults to 'int' [-Wimplicit-int]
 voiddisplay()
 ^
prog.c: In function 'voiddisplay':
prog.c:68:1: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
 system("cls");
 ^
prog.c:69:1: error: 'inti' undeclared (first use in this function)
 inti,j,k;
 ^
prog.c:69:6: error: 'j' undeclared (first use in this function)
 inti,j,k;
      ^
prog.c:69:5: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 inti,j,k;
     ^
prog.c:69:8: error: 'k' undeclared (first use in this function)
 inti,j,k;
        ^
prog.c:69:7: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 inti,j,k;
       ^
prog.c:70:5: error: 'i' undeclared (first use in this function)
 for(i=0;i<4;i++)
     ^
prog.c:74:4: error: 'ukladanka' undeclared (first use in this function)
 if(ukladanka[k][i])
    ^
prog.c:75:1: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
 printf("\xda\xc4\xc4\xc4\xc4\xbf");
 ^
prog.c:75:1: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:75:1: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:77:1: warning: incompatible implicit declaration of built-in function 'printf'
 printf("");
 ^
prog.c:77:1: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:77:8: warning: zero-length gnu_printf format string [-Wformat-zero-length]
 printf("");
        ^
prog.c:79:1: warning: incompatible implicit declaration of built-in function 'printf'
 printf("\r\n");
 ^
prog.c:79:1: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:85:8: warning: zero-length gnu_printf format string [-Wformat-zero-length]
 printf("");
        ^
prog.c:93:8: warning: zero-length gnu_printf format string [-Wformat-zero-length]
 printf("");
        ^
prog.c: At top level:
prog.c:99:1: warning: return type defaults to 'int' [-Wimplicit-int]
 voidcheckForWin()
 ^
prog.c:104:1: warning: return type defaults to 'int' [-Wimplicit-int]
 intkbhandle()
 ^
prog.c: In function 'intkbhandle':
prog.c:107:1: error: 'intch' undeclared (first use in this function)
 intch=getch();
 ^
prog.c:107:7: warning: implicit declaration of function 'getch' [-Wimplicit-function-declaration]
 intch=getch();
       ^
prog.c:108:4: error: 'ch' undeclared (first use in this function)
 if(ch==224||ch==0)
    ^
prog.c:113:1: error: 'returnCMD_UP' undeclared (first use in this function)
 returnCMD_UP;
 ^
prog.c:115:1: error: 'returnCMD_DOWN' undeclared (first use in this function)
 returnCMD_DOWN;
 ^
prog.c:117:1: error: 'returnCMD_LEFT' undeclared (first use in this function)
 returnCMD_LEFT;
 ^
prog.c:119:1: error: 'returnCMD_RIGHT' undeclared (first use in this function)
 returnCMD_RIGHT;
 ^
prog.c:121:1: error: 'returnCMD_NONE' undeclared (first use in this function)
 returnCMD_NONE;
 ^
prog.c:125:1: error: 'returnCMD_QUIT' undeclared (first use in this function)
 returnCMD_QUIT;
 ^
prog.c:127:1: error: 'returnCMD_SHUFFLE' undeclared (first use in this function)
 returnCMD_SHUFFLE;
 ^
prog.c:118:1: warning: label 'case77' defined but not used [-Wunused-label]
 case77:
 ^
prog.c:116:1: warning: label 'case75' defined but not used [-Wunused-label]
 case75:
 ^
prog.c:114:1: warning: label 'case80' defined but not used [-Wunused-label]
 case80:
 ^
prog.c:112:1: warning: label 'case72' defined but not used [-Wunused-label]
 case72:
 ^
prog.c: At top level:
prog.c:131:1: error: expected identifier or '(' before '{' token
 {
 ^
prog.c: In function 'voidinit':
prog.c:31:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prog.c: In function 'voidswapIndexes':
prog.c:38:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prog.c: In function 'voidmove':
prog.c:64:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prog.c: In function 'voiddisplay':
prog.c:97:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prog.c: In function 'voidcheckForWin':
prog.c:102:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prog.c: In function 'intkbhandle':
prog.c:129:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty