Advertisement
Guest User

lab6

a guest
May 31st, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. using namespace std;
  4. typedef int matr[4][8];
  5. typedef int mas[4];
  6. void input(matr a, int n, int m)
  7. {
  8.     for (int i = 0;i < n;i++)
  9.         for (int j = 0;j < m;j++)
  10.             a[i][j] = 1 + rand() % 10;
  11. }
  12. void output(matr a, int n, int m)
  13. {
  14.     for (int i = 0;i < n;i++)
  15.     {
  16.         for (int j = 0;j < m;j++)
  17.             cout << a[i][j] << "|";
  18.         cout << endl;
  19.     }
  20. }
  21. void form(matr a, mas b, int n, int m)
  22. {
  23.  
  24.     for (int i = 0;i < n;i++)
  25.     {
  26.         b[i] = 0;
  27.         for (int j = 0;j < m;j++)
  28.         {
  29.             int max = a[0][j];
  30.             if (a[i][j] > max)
  31.                 max = a[i][j];
  32.                 b[i]++;
  33.         }
  34.  
  35.  
  36.     }
  37. }
  38. void output_mas(mas a, int m)
  39. {
  40.     for (int i = 0;i < m;i++)
  41.         cout << a[i] << "|";
  42.     cout << endl;
  43. }
  44. int main()
  45. {
  46.     setlocale(LC_ALL, "rus");
  47.     matr a, b;
  48.     mas p, q;
  49.     input(a, 4, 8);
  50.     cout << "МАТРИЦА А= " << endl;
  51.     output(a, 4, 8);
  52.     input(b, 4, 8);
  53.     cout << "МАТРИЦА Б= " << endl;
  54.     output(b, 4, 8);
  55.     form(a, p, 4, 8);
  56.     form(b, q, 4, 8);
  57.     cout << "МАССИВ P" << endl;
  58.     output_mas(p, 4);
  59.     cout << "МАССИВ q" << endl;
  60.     output_mas(q, 4);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement