Advertisement
LabiinfaCibGyti

laba7.1

Dec 23rd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8.     int i=5, j=5;
  9.     double r=-3000000, k=0;
  10.         double m[5][5]={ {-3.8, 0, 5.3, 4.5, 0.5,},
  11.                             {0.2, -1.3, 0, -8.5, 3.5,},
  12.                             {-1.1, 1.8, 5.1, -8.2, 0.32,},
  13.                             {0, -0.3, 0, -1.28, 0.52,},
  14.                             {-0.3, 0.5, 1.8, -7.3, 5.5,} };
  15.         double x[5];
  16.         setlocale(0, "rus");
  17.         cout<<"Матрица 1"<<endl;
  18.         for (i=0; i<5;i++)
  19.         {
  20.             for (j=0; j<5; j++)
  21.             {
  22.                 cout<<m[i][j]<<"\t\t ";
  23.             }
  24.             cout<<endl;
  25.         }
  26.         cout<<"Массив №2"<<endl;
  27.         for (i=0; i<5;i++)
  28.         {
  29.             x[i]=m[i][i];
  30.         }
  31.         for (i=0; i<5; i++)
  32.         {
  33.             cout<<x[i]<<"  "<<endl;
  34.             if (x[i]>r)
  35.             {
  36.                 r=x[i];
  37.                 k=i;
  38.             }
  39.         }
  40.         cout<<endl;
  41.         cout<<"Максимальный элемент второго массива= "<<r<<"\t Его номер= "<<k+1<<endl;
  42.     return 0;
  43.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement