Advertisement
Guest User

Untitled

a guest
May 4th, 2021
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <string>
  5. #include <math.h>
  6. #include <vector>
  7. #include <iterator>
  8.  
  9. using namespace std;
  10. ////////////////////////
  11. void RusText(void);
  12.  
  13. int main(int argc, char **argv)
  14. {
  15. RusText();
  16.  
  17. int K,P, data;
  18. cout << "Введите количество строк = "; cin >> K ;
  19. cout << "Введите количество столбцов = "; cin >> P;
  20.  
  21. vector <vector <int> > A(K);
  22.  
  23. /* Ввод значений */
  24.  
  25. for (int row=0; row<K; row++)
  26. {
  27. for (int col=0; col<P; col++)
  28. {
  29. cin >> data; A[row].push_back(data);
  30. }
  31. }
  32.  
  33. // Для отладки и контроля заполнения массива векторов
  34.  
  35. cout<<endl; system("pause");
  36.  
  37. for (int row=0; row<K; row++)
  38. {
  39. for (int col=0; col<P; col++)
  40. {
  41. cout << A[row][col] << "\t";
  42. }
  43. cout << endl;
  44. }
  45.  
  46. // Ищем сумму строк
  47.  
  48. cout << endl; bool flag= false;
  49.  
  50. for (int row= 0; row< K; row++)
  51. {
  52. int sum= 0;
  53. for (int col=0; col< P; col++)
  54. {
  55. sum= sum + A[row][col];
  56. }
  57. A[row].push_back(sum);
  58. }
  59.  
  60. int mini= 0;
  61.  
  62. // Поиск минимальной суммы строки
  63.  
  64. for (int row=1; row<K; row++)
  65. {
  66. for (int col=0; col<P; col++)
  67. {
  68. if (A[mini][P] > A[row][P])
  69. {
  70. A[mini].pop_back(); //Удаляем из вектора сумму строки попутно
  71. mini= row;
  72. }
  73. }
  74. }
  75.  
  76. cout <<endl << "Сумма строки " << mini << "\t равна " << A[mini][P] << endl;
  77.  
  78. A.erase(A.begin() + mini); K--;
  79.  
  80. for (int row=0; row<K; row++)
  81. {
  82. for (int col=0; col<P; col++)
  83. {
  84. cout << A[row][col] << "\t";
  85. }
  86. cout << endl;
  87. }
  88.  
  89.  
  90. cout<<endl; system("pause");
  91. return 0;
  92. }
  93.  
  94. ////////// Руссификация сообщений //////////////////////////////////
  95.  
  96. void RusText(void)
  97. {
  98. system("chcp 1251 > nul");
  99. SetConsoleTitle(TEXT("ОтветыМейлРу")); //Для совместимости с VS
  100. return;
  101. }
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement