Advertisement
Guest User

1.b

a guest
Jan 28th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. // 1.b
  2. #include <math.h>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.   int top;
  9.   int bottom;
  10.   int height;
  11.   cin >> top >> bottom >> height;
  12.  
  13.   if (top > bottom) {
  14.     cout << "Нижнее оснавание должно быть больше верхнего" << endl;
  15.     return 1;
  16.   }
  17.  
  18.   if (top <= 0 || bottom <= 0 || height <= 0) {
  19.     cout << "Длинна не может быть 0" << endl;
  20.     return 1;
  21.   }
  22.  
  23.   int bok = sqrt(pow(height, 2) + pow((bottom - top) / 2, 2));
  24.   int p = top + bottom + bok * 2;
  25.  
  26.   cout << "Периметр: " << p;
  27.  
  28.   return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement