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

爱吃老友粉 1年前 已收到1个回答 举报

小飞虫11 春芽

共回答了16个问题采纳率:93.8% 举报

#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

1年前

2
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 18 q. 0.576 s. - webmaster@yulucn.com