evcamels

lr-5-19(4)

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