Advertisement
MARSHAL327

Untitled

Nov 25th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <conio.h>
  6.  
  7. using namespace std;
  8. class cheslo;
  9. class matr
  10. {
  11. private:
  12.     int** x;
  13.     int n, m;
  14.     int i, j, min;
  15.  
  16. public:
  17.     matr() {};
  18.     matr(int);
  19.     void vvod();
  20.     void vivod();
  21.     void razmer();
  22.     void sort();
  23.  
  24.     friend void sravnenie(matr* M, cheslo c);
  25. };
  26.  
  27. class cheslo
  28. {
  29.  
  30. private:
  31.     int c;
  32. public:
  33.     cheslo() { c = 0; };
  34.     //cheslo(int);
  35.     void vvch();
  36.     void vivch();
  37.  
  38.     friend void sravnenie(matr* M, cheslo c);
  39. };
  40. //-----------------------------------------------------------—
  41. void cheslo::vvch()
  42. {
  43.  
  44.     cout << "Введите число " << endl;
  45.     cin >> c;
  46. }
  47. //-----------------------------------------------------------—
  48.  
  49.  
  50.  
  51.  
  52.  
  53. //-----------------------------------------------------------—
  54. void cheslo::vivch()
  55. {
  56.     cout<<c<<endl;
  57. }
  58. //-----------------------------------------------------------—
  59.  
  60.  
  61.  
  62.  
  63. //-----------------------------------------------------------—
  64. void matr::razmer()
  65. {
  66.     cout << "Введите размер матрици[n x m]: " << endl;
  67.     cin >> n >> m;
  68.  
  69. }
  70. //-----------------------------------------------------------—
  71.  
  72.  
  73.  
  74. //-----------------------------------------------------------—
  75. void matr::vvod()
  76. {
  77.  
  78.     x = new int* [n];
  79.     for (int i = 0; i < n; i++)
  80.         x[i] = new int[m];
  81.  
  82.     cout << "Введите элементы масива:"<<endl;
  83.     for (int i = 0; i < n; i++)
  84.         for (int j = 0; j < m; j++)
  85.         {
  86.             cin>>x[i][j];
  87.         }
  88. }
  89. //-----------------------------------------------------------—
  90.  
  91.  
  92.  
  93. //-----------------------------------------------------------—
  94. void matr::vivod()
  95. {
  96.  
  97.  
  98.     cout << "Матрица :"<<endl;
  99.     for (int i = 0; i < n; i++)
  100.     {
  101.         for (int j = 0; j < m; j++)
  102.             cout <<x[i][j]<<" ";
  103.         cout <<endl;
  104.  
  105.     }
  106. }
  107. //-----------------------------------------------------------—
  108.  
  109.  
  110.  
  111. //-----------------------------------------------------------—
  112. void matr::sort()
  113. {
  114.     min = x[0][0];
  115.     for (int i = 0; i < n; i++)
  116.         for (int j = 0; j < m; j++)
  117.             if (min > x[i][j])
  118.                 min = x[i][j];
  119.     cout << min<<endl;
  120. }
  121. //-----------------------------------------------------------—
  122.  
  123. //-----------------------------------------------------------—
  124. void sravnenie(matr* M, cheslo c)
  125. {
  126.     /*int min = 0, c = 0;
  127.     if (c. == c)
  128.         cout << "равенство верно " << endl;
  129.     else
  130.         cout << "равенство неверно " << endl;*/
  131. }
  132.  
  133. //-----------------------------------------------------------—
  134.  
  135. int main()
  136. {
  137.     setlocale(LC_ALL, "rus");
  138.  
  139.     matr a;
  140.     cheslo ch;
  141.  
  142.     a.razmer();
  143.  
  144.     a.vvod();
  145.     ch.vvch();
  146.     ch.vivch();
  147.     a.sort();
  148.     a.vivod();
  149.     sravnenie(&a, ch);
  150.     return 0;
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement