fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. class Math
  6. {
  7. private:
  8. int num1;
  9. int num2;
  10. int num3;
  11. int num4;
  12. int num5;
  13. int num6;
  14.  
  15. public:
  16.  
  17. Math (int first, int second, int third, int fourth, int fifth, int sixth);
  18.  
  19. int Largest ();
  20. int Smallest ();
  21. };
  22.  
  23. Math::Math (int first, int second, int third, int fourth, int fifth, int sixth)
  24. {
  25. num1 = first;
  26. num2 = second;
  27. num3 = third;
  28. num4 = fourth;
  29. num5 = fifth;
  30. num6 = sixth;
  31.  
  32. return;
  33. }
  34.  
  35. int Math::Largest ()
  36. {
  37. int answer;
  38.  
  39. answer = num1;
  40.  
  41. if (num2 > answer)
  42. answer = num2;
  43. if (num3 > answer)
  44. answer = num3;
  45. if (num4 > answer)
  46. answer = num4;
  47. if (num5 > answer)
  48. answer = num5;
  49. if (num6 > answer)
  50. answer = num6;
  51.  
  52. return answer;
  53. }
  54.  
  55. int Math::Smallest ()
  56. {
  57. int answer;
  58.  
  59. answer = num1;
  60.  
  61. if (num2 < answer)
  62. answer = num2;
  63. if (num3 < answer)
  64. answer = num3;
  65. if (num4 < answer)
  66. answer = num4;
  67. if (num5 < answer)
  68. answer = num5;
  69. if (num6 < answer)
  70. answer = num6;
  71.  
  72. return answer;
  73. }
  74.  
  75. int main()
  76. {
  77. Math test1 (7,69,3,4,5,6);
  78. int solu = test1.Smallest();
  79. cout << solu;
  80. solu = test1.Largest();
  81. cout << solu;
  82. return 0;
  83. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
369