aLT22

Trusov's_Programm (C++) Matrix_Lab

May 20th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void work(int **A, int a, int b);
  6.  
  7. void main() {
  8.     setlocale (LC_ALL, "Russian");
  9.     int rowdim, coldim;
  10.     cin >> rowdim >> coldim;
  11.     int **matrix = new int *[rowdim];
  12.     for (int i = 0; i < rowdim; i++) {
  13.         matrix[i] = new int [coldim];
  14.     }
  15.     for (int i = 0; i < rowdim; i++) {
  16.         for (int j = 0; j < coldim; j++) {
  17.             matrix[i][j] = rand() % 10;
  18.         }
  19.     }
  20.     for (int i = 0; i < rowdim; i++) {
  21.         for (int j = 0; j < coldim; j++) {
  22.             cout << matrix[i][j] << ' ';
  23.         }
  24.         cout << endl;
  25.     }
  26.     work(matrix, rowdim, coldim);
  27.     delete []matrix;
  28.     system("pause");
  29. }
  30.  
  31. void work(int **A, int k, int l) {
  32.     for (int i = 0; i < k; i++) {
  33.         for (int j = 0; j < l; j++) {
  34.             if (!(j % 2)) {
  35.                 cout << A[i][j] << ' ';
  36.             }
  37.         }
  38.         cout << endl;
  39.     }
  40.    
  41. }
Advertisement
Add Comment
Please, Sign In to add comment