for(int i=1; i<=3; i++){
for (int j=1;j<=3;j++){
do{
themap[i][j]=rand()%9 +1;
for(c=1;c<=3;c++){
for(int l=1;l<=3;l++){
if(themap[i][j]==themap[c][l] && (i!=c || j!=l)){
ok=1;
}
}
}
} while (ok==1);
}
}
for(int k=1;k<=3;k++){
for(int l=1;l<=3;l++){
cout<<themap[k][l]<<" ";
}
cout<<endl;
}
So I built this program. Basically, I wanted a 3x3 array that will have random numbers between 1 and 9, but different ones. For some reason, when I run the program it shows nothing on the screen. All declarations of variables were done. Can you please tell me what's wrong? Thanks!
Aucun commentaire:
Enregistrer un commentaire