fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void printArray( int **array, int count )
  5. {
  6. for ( int i = 0; i < count; i++ )
  7. for (int j = 0; j < count; j++)
  8. cout << array[ i ][j] << " ";
  9. cout << endl;
  10. }
  11.  
  12. int main () {
  13. int n;
  14. cout<<"Please enter the length of your matrix : "<<endl;
  15. cin>>n;
  16. int **y = new int* [n];
  17. for (int w = 0; w <= n-1; w++ ) {
  18.  
  19. y[w] = new int [n];
  20. cout<<"Insert the elements ";
  21.  
  22. for (int z = 0; z <= n-1; z++)
  23. {
  24. cin >>y [w][z];
  25. }
  26. }
  27.  
  28. printArray(y, n);
  29.  
  30. }
Runtime error #stdin #stdout 0.02s 3752KB
stdin
Standard input is empty
stdout
Please enter the length of your matrix :