Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. class Sovershennoye_number
  5. {
  6. private:
  7. int N, sum;
  8. public:
  9. void set_N(int buf1)
  10. {
  11. N = buf1;
  12. }
  13. int get_N()
  14. {
  15. return N;
  16. }
  17. void set_Sum(int buf2)
  18. {
  19. sum = buf2;
  20. }
  21. int get_Sum()
  22. {
  23. return sum;
  24. }
  25. void summa_deliteley(int N)
  26. {
  27. for (int i = 1; i < N; i++)
  28. {
  29. if (N % i == 0)
  30. {
  31. sum += i;
  32. }
  33.  
  34. }
  35. if (sum == N)
  36. {
  37. cout << "Да. Это число совершенное " << endl;
  38. }
  39. else
  40. {
  41. cout << "Нет . Это число не совершенное" << endl;
  42. }
  43. }
  44. };
  45. int main()
  46. {
  47. setlocale(LC_ALL, "Rus");
  48. int buf1 ,buf2,buf3;
  49. buf2 = 0;
  50. cout << "Совершенное ли число ?" << endl;
  51. cout << "Введите число " << endl;
  52. cin >> buf1;
  53. Sovershennoye_number examp;
  54. examp.set_N(buf1);
  55. examp.set_Sum(buf2);
  56. buf3 = examp.get_N();
  57. examp.summa_deliteley(buf3);
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement