Advertisement
LabiinfaCibGyti

laba7.13

Jan 16th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 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, j,k=0;
  9.     double max=-20;
  10.         double a[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 b[25];
  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<<a[i][j]<<"\t\t ";
  23.             }
  24.             cout<<endl;
  25.         }
  26.         for (i=0;i<5;i++)
  27.         {
  28.             for (j=0; j<5-i;j++)
  29.             {
  30.                 b[k]=a[i][j];
  31.                 k++;
  32.             }
  33.         }
  34.         cout<<endl;
  35.         cout<<"Массив №2"<<endl;
  36.         for (i=0; i<k; i++)
  37.         {
  38.             cout<<b[i]<<endl;
  39.             if (b[i]>max)
  40.                 max=b[i];
  41.         }
  42.         cout<<endl;
  43.         cout<<"Максимальный элемент второго массива= "<<max<<endl;
  44.     return 0;
  45.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement