Advertisement
evcamels

lr-1

Dec 1st, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. using namespace std;
  5. class square{
  6.     float a;
  7. public:
  8.     void set(float a){
  9.         this->a = a;
  10.     }
  11.     float _square(){
  12.         return a*a;
  13.     }
  14.     float _perimeter(){
  15.         return 4*a;
  16.     }
  17.     float _diagonal(){
  18.         return sqrt(a*a + a*a);
  19.     }
  20. };
  21. class pyramid : public square{
  22.     float h;
  23. public:
  24.     void set1(float h){
  25.         this->h = h;
  26.     };
  27.     float _volume(){
  28.         return (0.3 * h * _square());
  29.     }
  30. };
  31. int main() {
  32.     int n,m,h;
  33.     vector <int> a,b;
  34.     cin >> n >> m >> h;
  35.     for(int i=0;i<n;i++){
  36.         int temp;
  37.         cin >> temp;
  38.         a.push_back(temp);
  39.     }
  40.     for(int i=0;i<m;i++){
  41.         int temp;
  42.         cin >> temp;
  43.         b.push_back(temp);
  44.     }
  45.     int count = 999999;
  46.     pyramid p;
  47.     for(int i=0;i<n;i++){
  48.         p.set(a[i]);
  49.         p._square();
  50.         cout << "Площадь " << i+1 << " квадрата: " << p._square() << endl;
  51.         if(count > p._square()){
  52.             count = p._square();
  53.         }
  54.     }
  55.     cout << "Минимальная площадь квадрата: " << count << endl;
  56.     for(int i=0;i<m;i++){
  57.         p.set1(b[i]);
  58.         cout << "Объем " << i+1 << " пирамиды: "<< p._volume() << endl;
  59.         if(b[i] > h){
  60.             cout << i+1 << " пирамида имеет h больше заданной: " << b[i] << endl;
  61.         }
  62.     }
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement