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>
- ///////////////////////////////////
- using namespace std;
- //////////////////////////////////
- class Matr7x7
- {
- public:
- vector <double> Row;
- vector < vector <double> > matr77;
- double MulMatrNeg;
- ////////////////////////
- Matr7x7()
- {
- MulMatrNeg= 0.0;
- }
- /////////////////////////
- void InitMatr()
- {
- double el;
- for (int rows= 0; rows< 7; rows++)
- {
- for (int cols=0; cols< 7; cols++)
- {
- el= (double) rows *10.0 + (double) cols;
- Row.push_back(el);
- }
- matr77.push_back(Row);
- Row.erase(Row.begin(), Row.end());
- }
- //Тестовая модификация матрицы
- matr77[0][5]= -5.0;
- matr77[5][0]= -4.0;
- matr77[6][6]= -10.0;
- matr77[0][6]= -50.0;
- }
- /////////////////////
- void OutMatr77()
- {
- for (int rows= 0; rows< 7; rows++)
- {
- for (int cols=0; cols< 7; cols++)
- {
- cout << setw(5) << matr77[rows][cols];
- }
- cout<< endl;
- }
- }
- /////////////////////
- void MULELNEG()
- {
- int param= 6;
- for (int rows= 0; rows< 7; rows++)
- {
- for (int cols=0; cols< param; cols++)
- {
- if (matr77[rows][cols]<0)
- MulMatrNeg= MulMatrNeg+matr77[rows][cols]*matr77[rows][cols];
- }
- param--;
- }
- cout << "Сумма квадратов отрицательных элементов" << endl;
- cout << "матрицы 7х7 выше побочной диагонали" << endl;
- cout << "составляет " << MulMatrNeg << endl;
- }
- };
- ////////////////////////////////////
- int main(int argc, char **argv)
- {
- system("chcp 1251 > nul"); // Руссификация сообщений
- setlocale(LC_ALL, "Russian");
- Matr7x7 mt7; mt7.InitMatr(); mt7.OutMatr77(); mt7.MULELNEG();
- system("pause"); // system("pause > nul");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement