Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <math.h>
- #include <vector>
- #include <iterator>
- using namespace std;
- ////////////////////////
- void RusText(void);
- int main(int argc, char **argv)
- {
- RusText();
- int K,P, data;
- cout << "Введите количество строк = "; cin >> K ;
- cout << "Введите количество столбцов = "; cin >> P;
- vector <vector <int> > A(K);
- /* Ввод значений */
- for (int row=0; row<K; row++)
- {
- for (int col=0; col<P; col++)
- {
- cin >> data; A[row].push_back(data);
- }
- }
- // Для отладки и контроля заполнения массива векторов
- cout<<endl; system("pause");
- for (int row=0; row<K; row++)
- {
- for (int col=0; col<P; col++)
- {
- cout << A[row][col] << "\t";
- }
- cout << endl;
- }
- // Ищем сумму строк
- cout << endl; bool flag= false;
- for (int row= 0; row< K; row++)
- {
- int sum= 0;
- for (int col=0; col< P; col++)
- {
- sum= sum + A[row][col];
- }
- A[row].push_back(sum);
- }
- int mini= 0;
- // Поиск минимальной суммы строки
- for (int row=1; row<K; row++)
- {
- for (int col=0; col<P; col++)
- {
- if (A[mini][P] > A[row][P])
- {
- A[mini].pop_back(); //Удаляем из вектора сумму строки попутно
- mini= row;
- }
- }
- }
- cout <<endl << "Сумма строки " << mini << "\t равна " << A[mini][P] << endl;
- A.erase(A.begin() + mini); K--;
- for (int row=0; row<K; row++)
- {
- for (int col=0; col<P; col++)
- {
- cout << A[row][col] << "\t";
- }
- cout << endl;
- }
- cout<<endl; system("pause");
- return 0;
- }
- ////////// Руссификация сообщений //////////////////////////////////
- void RusText(void)
- {
- system("chcp 1251 > nul");
- SetConsoleTitle(TEXT("ОтветыМейлРу")); //Для совместимости с VS
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement