Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <vector>
- #include <time.h>
- #include <stdio.h>
- #include <stdlib.h>
- //#include <algorithm>
- using namespace std;
- class MatrVect
- {
- public:
- int Row;
- int Col;
- int data;
- vector <int> Clmn;
- vector < vector <int> > Mtr;
- MatrVect()
- {
- cout << "Введите размерность матрицы Строки / Столбцы\t";
- cin >> Row >> Col;
- }
- MatrVect(int rr, int cc)
- {
- Row= rr; Col= cc;
- }
- void InitMatr()
- {
- srand (time(NULL));
- for (int r0= 0; r0<Row; r0++)
- {
- for (int c0= 0; c0<Col; c0++)
- {
- //data = rand()%100);
- data=(r0+1)*10+(c0+1);
- Clmn.push_back(data);
- }
- Mtr.push_back(Clmn);
- Clmn.erase(Clmn.begin(), Clmn.end());
- }
- Mtr[Row/2][Col/2]= 100;
- Mtr[Row/3][Col/3]= -100;
- }
- ////////////////////
- void ShowMatr()
- {
- for (int r0= 0; r0<Row; r0++)
- {
- for (int c0= 0; c0<Col; c0++)
- {
- cout << Mtr[r0][c0] << "\t";
- }
- cout << endl;
- }
- }
- //////////////////////
- ~MatrVect() {}
- /////////////////
- void Func()
- {
- int rmax, sum, cmin, res;
- sum= 0; rmax= 0; res= 0;
- for (int ind=0; ind<Col; ind++) res+=Mtr[0][ind];
- for (int r= 1; r< Row; r++)
- {
- for (int ind=0; ind<Col; ind++) sum+=Mtr[r][ind];
- if (sum>res) { rmax = r; res = sum; sum = 0; }
- }
- sum= 0; cmin= 0; res= 0;
- for (int ind=0; ind<Row; ind++) res+=Mtr[ind][0];
- for (int c= 1; c< Col; c++)
- {
- for (int ind=0; ind<Row; ind++) sum+=Mtr[ind][c];
- if (sum<res) { cmin = c; res = sum; sum = 0; }
- }
- cout << "Строка с максимальной суммой " << rmax << endl;
- cout << "Столбец с минимальной суммой " << cmin << endl;
- }
- ///////////////////
- protected:
- private:
- };
- ///////////////////////////////////
- int main(int argc, char **argv)
- {
- system("chcp 1251 > nul");
- SetConsoleTitle(TEXT("Ответы"));
- //MatrVect mv(5,5);
- MatrVect mv;
- mv.InitMatr();
- mv.ShowMatr();
- mv.Func();
- cout<<endl; system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement