Advertisement
evcamels

lab-1_var-1

Nov 16th, 2021
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 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 prism : public square{
  22.     float a;
  23. public:
  24.     void set1(float a){
  25.         this->a = a;
  26.     };
  27.     float _volume(){
  28.         return (a* sqrt(3));
  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 = 0;
  46.     prism 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.     int count1 = 0;
  57.     for(int i=0;i<m;i++){
  58.         p.set1(b[i]);
  59.         cout << "Диагональ " << i+1 << " призмы: "<< p._volume() << endl;
  60.         if(count1 < p._volume()){
  61.             count1=p._volume();
  62.         }
  63.     }
  64.     cout<< "Призма с большей диагональю: " << count1 << endl;
  65.     return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement