codice:#include<iostream> #include<time.h> #include<stdlib.h> using namespace std; int main () { srand(time(NULL)); char t[15][15]; int i,j; char x='-'; char a='A'; char b='1'; for(j=0;j<10;j++) { for (i=0;i<11;i++) { if(j==0&&i!=10) { t[i][j]=a; cout<<" "<<t[i][j]; a++; } else if(j!=0&&i==0) { t[i][j]=b; cout<<t[i][j]; b++;} else if(j!=0){t[i][j]=x; cout<<" "<<t[i][j]<<" ";} } cout<<endl; } cout<<endl<<endl; int z=0,w=0; int orie=rand()%2; bool occ=false; if (orie==0) { while(z==0) z=rand()%8; while(w==0) w=rand()%10; for(i=z;i<z+4;i++) {t[i][w]='o';} } else if(orie==1) { while(z==0) z=rand()%11; while(w==0) w=rand()%7; for(j=w;j<w+4;j++) {t[z][j]='o';} } for (int k=0;k<2;k++) { do { orie=rand()%2; if(orie==0) { while(z==0) z=rand()%9; while(w==0) w=rand()%10; if(t[z][w]=='o' or t[z+1][w]=='o' or t[z+2][w]=='o') occ=true; else {t[z][w]='o';t[z+1][w]='o'; t[z+2][w]='o';} } else if(orie==1) { while(z==0) z=rand()%11; while(w==0) w=rand()%8; if(t[z][w]=='o' or t[z][w+1]=='o' or t[z][w+2]=='o') occ=true; else{t[z][w];t[z][w+1]='o'; t[z][w+2]='o';} } } while(occ==true); } for(j=0;j<10;j++) { for(i=0;i<11;i++){ if(j==0) { cout<<" "<<t[i][j]; } else if(j!=0&&i!=0) {cout<<" "<<t[i][j]<<" ";} else cout<<t[i][j];} cout<<endl;} }
ho bisogno di aiuto con questo codice. il compilatore lo compila ma quando lo eseguo il programma si blocca dopo aver disegnato la prima matrice