#include //arvestus ylesanne int m[10][10]={ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 3, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 3, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; int Valjastamangulaud(){ int i,j; printf(" 1 2 3 4 5 6 7 8 9 10\n"); printf("\n"); for(i=0; i<10; i++){ if(i<9){ //selleks et numbrid oleksid kohakuti printf(" %d ", i+1); }else{ printf("%d ", 10); } for(j=0; j<10; j++){ switch(m[i][j]){ case 1: printf(" +"); break; case 2: printf(" X"); break; case 3: printf(" O"); break; default: printf(" %d", m[i][j] ); } } printf("\n"); } printf("\n"); printf(" 1 2 3 4 5 6 7 8 9 10\n"); printf("\n"); } int main(void){ char k2ik ,enter; //int k=(int)k2ik; //int k=2,l=2,n=4,o=6; int k,l,n,o; int i,j,nupud=1,kord=0, loendur=0; int u; srand(); k=rand()%10; l=rand()%10; n=rand()%10; o=rand()%10; m[l][k]=1; m[o][n]=2; Valjastamangulaud(); printf("v-vasakule, p-paremale, y-yles, a-alla \n"); while(nupud>0){ //while algab if(kord==0){ printf("Mängija kord on liikuda!\n"); printf("\n"); } if(kord==1){ printf("Kolli kord on liikuda!\n"); printf("\n"); } if(kord==0){ printf(" kuhu sa minna soovid: "); scanf("%c%c", &k2ik, &enter); if(k2ik=='q') break; u=(int)k2ik; //tekst acii kood if(u==118){ if(m[l][k-1]!=2){ if(m[l][k-1]!=3){ m[l][k-1]=1; m[l][k]=0; k=k-1; } } } if(u==112){ if(m[l][k+1]!=2){ if(m[l][k+1]!=3){ m[l][k+1]=1; m[l][k]=0; k=k+1; } } } if(u==121){ if(m[l-1][k]!=2){ if(m[l-1][k]!=3){ m[l-1][k]=1; m[l][k]=0; l=l-1; } } } if(u==97){ if(m[l+1][k]!=2){ if(m[l+1][k]!=3){ m[l+1][k]=1; m[l][k]=0; l=l+1; } } } kord=1; }else{ if(k==n){ if(l