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(int rr, int cc)
- {
- srand((unsigned)time(0));
- Row= rr; Col= cc;
- for (int r0= 0; r0<Row; r0++)
- {
- for (int c0= 0; c0<Col; c0++)
- {
- data= rand() % 99;
- Clmn.push_back(data);
- }
- Mtr.push_back(Clmn);
- Clmn.erase(Clmn.begin(), Clmn.end());
- }
- }
- ////////////////////
- void ShowMatr()
- {
- for (int r0= 0; r0<Row; r0++)
- {
- for (int c0= 0; c0<Col; c0++)
- {
- cout << setw(3) << Mtr[r0][c0];
- }
- cout << endl;
- }
- }
- //////////////////////
- ~MatrVect() {}
- ///////////////////
- void FuncMain()
- {
- for (int c= 0; c < Col; c++)
- {
- data= 0;
- for (int r= 0; r < (Row-1); r++)
- {
- data+= Mtr[r][c];
- }
- data/= (Row-1);
- Mtr[Row-1][c]= data;
- }
- for (int c= 0; c < Col; c++)
- {
- data= 0;
- for (int r= 0; r < (Row-1); r++)
- {
- if (Mtr[r][c] < Mtr[Row-1][c]) data++;
- }
- Mtr[Row-1][c]= data;
- }
- }
- ///////////////////
- protected:
- private:
- };
- ///////////////////////////////////
- int main(int argc, char **argv)
- {
- system("chcp 1251 > nul");
- SetConsoleTitle(TEXT("Ответы"));
- int N,M;
- cout << "Введите N-размерность матрицы = "; cin >> N;
- cout << "Введите M-размерность матрицы = "; cin >> M;
- MatrVect mv(N+1,M); mv.FuncMain(); mv.ShowMatr();
- cout<<endl; system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement