Back to General discussions forum
void input(int** stmatrix,int rows,int cols); void print(int** stmatrix,int rows,int cols);
int main() { int rows; int cols;
std::cout << "enter the # of rows :" ;
std::cin >> rows;
std::cout << "enter the # of cols :" ;
std::cin >> cols;
int** stmatrix = new int*[rows];
input(stmatrix,rows,cols);
print(stmatrix,rows,cols);
return 0;
} void input(int** stmatrix,int rows,int cols) { for(int i = 0 ; i < rows ; i++ ) { stmatrix[i] = new int[cols]; for(int j = 0 ; j < cols ; j++ ) { std::cout << "enter R"<<i+1<< "C"<<j<< " : "; std::cin >> stmatrix[i][j]; } } } void print(int** stmatrix,int rows,int cols) { for(int i = 0 ; i < rows ; i++ ) { for(int j = 0 ; j < cols ; j++ ) { std::cout << stmatrix[i][j] << " "; } std::cout << "\n"; } }
Hi Friend!
Regretfully it seems your post doesn't contain any question, suggestion etc. If it is by mistake, just tell, I'll remove it.