Advertisement
Guest User

a guest
Sep 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "math.h"
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. class number {
  8. public: double value;
  9. number (double val):value(val){}
  10. double getabs() { return abs(value); }
  11. double getInt() { return (int)value; }
  12. };
  13.  
  14. class irrational : public number {
  15. public:
  16. using number::number;
  17. };
  18.  
  19.  
  20. int main()
  21. {
  22. setlocale(0, "");
  23. double a, b, c;
  24.  
  25. cout << "Введите число: \n";
  26. cin >> a;
  27. cin >> b;
  28. cin >> c;
  29.  
  30.  
  31. number n1(a);
  32. number n2(b);
  33. number n3(c);
  34.  
  35. cout << "Модуль числа: \n";
  36. cout << n1.getabs() << endl;
  37. cout << n2.getabs() << endl;
  38. cout << n3.getabs() << endl;
  39.  
  40. cout << "Целая часть: \n";
  41. cout << n1.getInt() << endl;
  42. cout << n2.getInt() << endl;
  43. cout << n3.getInt() << endl;
  44.  
  45. system("pause");
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement