Array-Random Choice

closed account (2E8qM4Gy)
j-> 6,8,13,24
I just wanna random chose one of these numbers but i can't
Can you help me? I know,i should make an array from these numbers and
then have a random number one of the length of the array.
At the end take the component that shown by random number of length of array.
But i can't, i try lots of way, make my mind mess.
At the end of my project i will have backgammon (a board game)
But this little block is on my way.

Thanks Already


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define line 16
#define columns 26

char dizi[line][columns];
int j;

int main(){
dizi[1][12]='X';dizi[2][12]='X';dizi[3][12]='X';dizi[4][12]='X';dizi[5][12]='X';
dizi[1][1]='X';dizi[2][1]='X';
dizi[1][17]='X';dizi[2][17]='X';dizi[3][17]='X';
dizi[1][19]='X';dizi[2][19]='X';dizi[3][19]='X';dizi[4][19]='X';dizi[5][19]='X';
dizi[1][8]='O';dizi[2][8]='O';dizi[3][8]='O';
dizi[1][6]='O';dizi[2][6]='O';dizi[3][6]='O';dizi[4][6]='O';dizi[5][6]='O';
dizi[1][13]='O';dizi[2][13]='O';dizi[3][13]='O';dizi[4][13]='O';dizi[5][13]='O';
dizi[1][24]='O';dizi[2][24]='O';

for(j=1;j<=24;j++){
if(dizi[1][j]=='O'){
printf("%i ",j);
}
}

printf("\n\n");
system("pause");
return 0;
}
Last edited on
Topic archived. No new replies allowed.