Advertisement
LabiinfaCibGyti

laba6.13

Jan 16th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. using namespace std;
  5. int _tmain(int argc, _TCHAR* argv[])
  6. {
  7.     setlocale (0,"rus");
  8.     int i, j;
  9.     double a=25.8, b[20], x, s=0, p=1, k;
  10.     for (i=0;i<20;i++)
  11.     {
  12.         k=i;
  13.         b[i]=sqrt(abs(pow(k+1,2)-a));
  14.     }
  15.     for (i=0;i<20;i++)
  16.     {
  17.         if (i>=4 && i<=9)
  18.             s=s+b[i];
  19.         if (b[i]<8.5)
  20.             p=p*b[i];
  21.         cout<<"B["<<i+1<<"]= "<<b[i]<<endl;
  22.     }
  23.     for (j=0;j<6;j++)
  24.     {
  25.         for (i=4;i<9;i++)
  26.         {
  27.             if (b[i]<b[i+1])
  28.             {
  29.                 x=b[i];
  30.                 b[i]=b[i+1];
  31.                 b[i+1]=x;
  32.             }
  33.         }
  34.     }
  35.     cout<<endl;
  36.     cout<<endl;
  37.     cout<<"Измененный массив"<<endl;
  38.     for (i=0;i<20;i++)
  39.     {
  40.         cout<<"B["<<i+1<<"]= "<<b[i]<<endl;
  41.     }
  42.     cout<<"Сумма элементов с номерами 5;10 = "<<s<<endl;
  43.     cout<<"Произведение чисел меньше 8.5 = "<<p<<endl;
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement