int rows = 0;
const int cols = 5;
int (*two_d_int_array)[cols];
cout<<"Please enter the number of rows: ";
cin>>rows;
two_d_int_array = new int[rows][cols];
for(int i=0; i<rows; i++)
for(int j=0; j<cols; j++)
two_d_int_array[i][j] = j+1;
for(int i=0; i<rows; i++){
for(int j=0; j<cols; j++){
cout<<two_d_int_array[i][j];
}
cout<<endl;
}
delete[] two_d_int_array;
No comments:
Post a Comment