1) 若正整数A的所有因子(包括1但不包括自身,下同)之和为B,而B的因子之和为A,则称A和B为一对亲密数.例
1个回答

#include

#include

int fun(int x) ;

int main()

{

int hat ;

printf("请输入想要多少对亲密数") ;

scanf("%d",&hat) ;

int *that1=new int [hat] ;

int *that2=new int [hat] ;

int a,j,b ;

int top=0 ;

for(a=3;;a++)

{

b=fun(a) ;

if(a==b)

continue ;

if(a==fun(b))

{

that1[top]=a ;

that2[top]=b ;

printf("%d%dn",a,b) ;

top++ ;

if(top%1000==0)

printf("%dn",top) ;

if(top>hat)

break ;

}

}

FILE *fp=fopen("D:\亲密数.txt","w");

for(int i=0;i

相关问题