Advertisement
Username77177

Dahl-Programming-Lab2-10

Sep 18th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.     //Задание 1
  9.     int a, b, c;
  10.     cout << "Введите значение a: ";
  11.     cin >> a;
  12.     cout << "Введите значение b: ";
  13.     cin >> b;
  14.     cout << "Введите значение c: ";
  15.     cin >> c;
  16.  
  17.     const int P = a + b + c; //периметр
  18.     int p = P / 2;           //Полупериметр
  19.     double geroninformula = p * (p - a) * (p - b) * (p - c); //Формула Герона
  20.     double S = sqrt(geroninformula);
  21.     cout << "Площадь треугольника с периметром " << P << " равна " << S << endl;
  22.  
  23.     //Задание 2
  24.     int x;
  25.     cout << "Введите x: ";
  26.     cin >> x;
  27.     double y = sqrt(3) * x - 2 * sin(x);
  28.     cout << "Корень из 3 * " << x << " - 2 * sin " << x << " = " << y << endl;
  29.    
  30.     //Задание 3
  31.     int c3;
  32.     cout<<"Введите трехзначное число: ";
  33.     cin >> c3;
  34.     int f = c3 /100;
  35.     int s = c3 /10 % 10;
  36.     int t = c3 % 10;
  37.     cout<<f+s+t<<endl;
  38.    
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement