Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Sovershennoye_number
- {
- private:
- int N, sum;
- public:
- void set_N(int buf1)
- {
- N = buf1;
- }
- int get_N()
- {
- return N;
- }
- void set_Sum(int buf2)
- {
- sum = buf2;
- }
- int get_Sum()
- {
- return sum;
- }
- void summa_deliteley(int N)
- {
- for (int i = 1; i < N; i++)
- {
- if (N % i == 0)
- {
- sum += i;
- }
- }
- if (sum == N)
- {
- cout << "Да. Это число совершенное " << endl;
- }
- else
- {
- cout << "Нет . Это число не совершенное" << endl;
- }
- }
- };
- int main()
- {
- setlocale(LC_ALL, "Rus");
- int buf1 ,buf2,buf3;
- buf2 = 0;
- cout << "Совершенное ли число ?" << endl;
- cout << "Введите число " << endl;
- cin >> buf1;
- Sovershennoye_number examp;
- examp.set_N(buf1);
- examp.set_Sum(buf2);
- buf3 = examp.get_N();
- examp.summa_deliteley(buf3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement