Untitled

 avatar
unknown
plain_text
4 years ago
597 B
5
Indexable
#include<iostream>
using namespace std;

unsigned int isPerfect(unsigned int n)
{
    unsigned int a=0;

    for (unsigned int i = 1; i < n; i++) {
        if (n % i == 0)a += i;
        }
    if (a != n) { 
        cout << n << " khong la so hoan hao"<<endl; 
    }
    else {
        cout << n << " la so hoan hao" << endl;
    }
    return a;
}
 
int main()
{
    unsigned int n;
    cout << "nhap so n de kiem tra: "; cin >> n; cout << endl;
    unsigned int (*contro)(unsigned int) = isPerfect;
    contro(n);
    cout << "tong cac uoc nho hon chinh no cua n: " << *contro(n);
    return 0;
}
Editor is loading...