- #include<stdio.h>
- #include<stdlib.h>
- int yin(int test);
- int sum(int a[],int num);
- int main(){
- int i=2,temp;
- for(i;i<1000;i++){
- temp=yin(i);
- if(temp!=0){
- printf("%d\\n",temp);
- }
- }
- system("pause");
- return 1;
- }
- int yin(int test){
- int i=1,j=0,k=0;
- for(i;i<test;i++){
- if(test%i==0){
- j++;
- }
- }
- int temp[j],t=0;
- for(i=1;i<test;i++){
- if(test%i==0){
- temp[t]=i;
- t++;
- }
- }
- if(test==sum(temp,j)){
- return test;
- }else{
- return 0;
- }
- }
- int sum(int a[],int num){
- int i=0,sum=0;
- for(i;i<num;i++){
- sum+=a[i];
- }
- return sum;
- }
- //该片段来自于http://www.codesnippet.cn/detail/171020136443.html
来源: http://www.codesnippet.cn/detail/171020136443.html