Advertisement
Guest User

Untitled

a guest
Apr 9th, 2022
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <string>
  6. #include <vector>
  7.  
  8. #include <time.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <algorithm>
  12.  
  13. using namespace std;
  14.  
  15. class MatrVect
  16. {
  17. public:
  18. int Row;
  19. int Col;
  20. int data;
  21.  
  22. vector <int> Clmn;
  23. vector < vector <int> > Mtr;
  24.  
  25. MatrVect(int rr, int cc)
  26. {
  27. srand((unsigned)time(0));
  28.  
  29. Row= rr; Col= cc;
  30. for (int r0= 0; r0<Row; r0++)
  31. {
  32. for (int c0= 0; c0<Col; c0++)
  33. {
  34. data= rand() % 99;
  35. Clmn.push_back(data);
  36. }
  37. Mtr.push_back(Clmn);
  38. Clmn.erase(Clmn.begin(), Clmn.end());
  39. }
  40. }
  41.  
  42. ////////////////////
  43.  
  44. void ShowMatr()
  45. {
  46. for (int r0= 0; r0<Row; r0++)
  47. {
  48. for (int c0= 0; c0<Col; c0++)
  49. {
  50. cout << setw(3) << Mtr[r0][c0];
  51. }
  52. cout << endl;
  53. }
  54. }
  55.  
  56. //////////////////////
  57.  
  58. ~MatrVect() {}
  59.  
  60.  
  61. ///////////////////
  62.  
  63. void FuncMain()
  64. {
  65. for (int c= 0; c < Col; c++)
  66. {
  67. data= 0;
  68. for (int r= 0; r < (Row-1); r++)
  69. {
  70. data+= Mtr[r][c];
  71. }
  72. data/= (Row-1);
  73. Mtr[Row-1][c]= data;
  74. }
  75.  
  76. for (int c= 0; c < Col; c++)
  77. {
  78. data= 0;
  79. for (int r= 0; r < (Row-1); r++)
  80. {
  81. if (Mtr[r][c] < Mtr[Row-1][c]) data++;
  82. }
  83. Mtr[Row-1][c]= data;
  84. }
  85.  
  86. }
  87.  
  88. ///////////////////
  89.  
  90. protected:
  91. private:
  92. };
  93.  
  94. ///////////////////////////////////
  95. int main(int argc, char **argv)
  96. {
  97. system("chcp 1251 > nul");
  98. SetConsoleTitle(TEXT("Ответы"));
  99.  
  100. int N,M;
  101. cout << "Введите N-размерность матрицы = "; cin >> N;
  102. cout << "Введите M-размерность матрицы = "; cin >> M;
  103.  
  104. MatrVect mv(N+1,M); mv.FuncMain(); mv.ShowMatr();
  105.  
  106. cout<<endl; system("pause");
  107. return 0;
  108. }
  109.  
  110.  
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement