Advertisement
Haru2k

Matrix C++, Printing out the colom which we will input

Sep 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "iostream"
  3. #include "ctime"
  4. #include "cstdlib"
  5.  
  6. using namespace std;
  7.  
  8. int ms[10][10];
  9. int n,m,d,i,g;
  10.  
  11. int main()
  12. {
  13.     srand(time(0));
  14.  
  15.     cout << "Please input the value for M and N: ";
  16.     cin >> m >> n;
  17.  
  18.     cout << "Please input the value for D: ";
  19.     cin >> d;
  20.  
  21.     cout << endl;
  22.  
  23.     cout << "There is a Matrix N*M: ";
  24.     cout << endl;
  25.  
  26.     //generate matrix
  27.     for (i = 0; i < m; i++)
  28.     {
  29.         for (g = 0; g < n; g++)
  30.         {
  31.             ms[i][g] = rand() % 100;
  32.         }
  33.     }
  34.  
  35.     //printing the output of matrix
  36.  
  37.     for (i = 0; i < m; i++)
  38.     {
  39.         for (g = 0; g < n; g++)
  40.         {
  41.             cout << ms[i][g] << " ";
  42.         }
  43.         cout << endl;
  44.     }
  45.     //printing the output of D col
  46.     cout << endl << "There is a D colom: " << endl;
  47.  
  48.     for (i = 0; i < m; i++)
  49.     {
  50.         cout << ms[i][d-1] << " ";
  51.     }
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement