#include<stdio.h>
#define N 1000
int main () {
int num,temp,i;
for(num=2;num<N;num++) {
temp=num;
for( i=1;i<=num;i++) {
if(num%i==0) {
temp=temp-i;
}
if(temp==0) {
printf("%d是完数,因子为:",num);
for( i=1;i<num;i++) {
if(num%i==0) {
printf("%d ",i);
}
}
printf("\n");
}
}
}
return 0;
}
/*
int main () {
int num,NN=1000,count=0;
int k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,s;
for(num=2;num<=NN;num++) {
count=0;
s=num;
for(int i=1;i<=num;i++) {
if(num%i==0) {
count++;
switch(count) {
case 1: k1=i;break;
case 2: k2=i;break;
case 3: k3=i;break;
case 4: k4=i;break;
case 5: k5=i;break;
case 6: k6=i;break;
case 7: k7=i;break;
case 8: k8=i;break;
case 9: k9=i;break;
case 10: k10=i;break;
}
s=s-i;
if(s==0){
printf("%d是完数,因子为:",num);
if(count>1) printf("%d,%d",k1,k2);
if(count>2) printf(",%d",k3);
if(count>3) printf(",%d",k4);
if(count>4) printf(",%d",k5);
if(count>5) printf(",%d",k6);
if(count>6) printf(",%d",k7);
if(count>7) printf(",%d",k8);
if(count>8) printf(",%d",k9);
if(count>9) printf(",%d",k10);
printf("\n");
}
}
}}
return 0;
} */