想看題目請點我
#include <iostream>
using namespace std;
main() {
int N ;
while(cin >> N)
{
if(N>0)
{
int S = 0 , length = 0 , Factor[N] ;
//取因數
for(int i = 1 ; i <= (N/2); i++ )
{
if((N%i)==0)
{
Factor[length] = i ;
length++ ;
}
}
//總和
for(int i = 0 ; i < length ; i++ )
{
S += Factor[i] ;
}
//印出
if(S > N)
{
cout << "盈數" << endl ;
}
else if(S==N)
{
cout << "完全數" << endl ;
}
else
{
cout << "虧數" << endl ;
}
}
}
}