Advertisement
Guest User

Untitled

a guest
Aug 18th, 2021
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <string>
  5. #include <vector>
  6. #include <time.h>
  7.  
  8. ///////////////////////////////////
  9.  
  10. using namespace std;
  11.  
  12. //////////////////////////////////
  13.  
  14. class Matr7x7
  15. {
  16. public:
  17. vector <double> Row;
  18. vector < vector <double> > matr77;
  19.  
  20. double MulMatrNeg;
  21.  
  22. ////////////////////////
  23.  
  24. Matr7x7()
  25. {
  26. MulMatrNeg= 0.0;
  27. }
  28.  
  29. /////////////////////////
  30.  
  31. void InitMatr()
  32. {
  33. double el;
  34. for (int rows= 0; rows< 7; rows++)
  35. {
  36. for (int cols=0; cols< 7; cols++)
  37. {
  38. el= (double) rows *10.0 + (double) cols;
  39. Row.push_back(el);
  40. }
  41. matr77.push_back(Row);
  42. Row.erase(Row.begin(), Row.end());
  43. }
  44.  
  45. //Тестовая модификация матрицы
  46. matr77[0][5]= -5.0;
  47. matr77[5][0]= -4.0;
  48. matr77[6][6]= -10.0;
  49. matr77[0][6]= -50.0;
  50. }
  51.  
  52. /////////////////////
  53.  
  54. void OutMatr77()
  55. {
  56. for (int rows= 0; rows< 7; rows++)
  57. {
  58. for (int cols=0; cols< 7; cols++)
  59. {
  60. cout << setw(5) << matr77[rows][cols];
  61. }
  62. cout<< endl;
  63. }
  64. }
  65.  
  66. /////////////////////
  67.  
  68. void MULELNEG()
  69. {
  70. int param= 6;
  71. for (int rows= 0; rows< 7; rows++)
  72. {
  73. for (int cols=0; cols< param; cols++)
  74. {
  75. if (matr77[rows][cols]<0)
  76. MulMatrNeg= MulMatrNeg+matr77[rows][cols]*matr77[rows][cols];
  77. }
  78. param--;
  79. }
  80. cout << "Сумма квадратов отрицательных элементов" << endl;
  81. cout << "матрицы 7х7 выше побочной диагонали" << endl;
  82. cout << "составляет " << MulMatrNeg << endl;
  83. }
  84.  
  85. };
  86.  
  87. ////////////////////////////////////
  88.  
  89. int main(int argc, char **argv)
  90. {
  91. system("chcp 1251 > nul"); // Руссификация сообщений
  92. setlocale(LC_ALL, "Russian");
  93.  
  94. Matr7x7 mt7; mt7.InitMatr(); mt7.OutMatr77(); mt7.MULELNEG();
  95.  
  96. system("pause"); // system("pause > nul");
  97. return 0;
  98. }
  99.  
  100.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement