#include<stdio.h>
main()
{
int a
,b
,c
,d
,e
,f
;
for(a
=1; a
<1000; a
++)
{
c
=0;
e
=0;
for(b
=1; b
<a
; b
++)
{
if(a
%b
==0)
c
+=b
;
}
if(c
==a
)
{
printf("%d its factors are",a
);
e
=c
;
}
for(b
=1; b
<a
; b
++)
{
c
=0;
if(a
%b
==0)
{
for(f
=1; f
<a
; f
++)
{
if(a
%f
==0)
c
+=f
;
}
if(c
==e
)
printf(" %d ",b
);
}
}
}
}
#include<stdio.h>
main()
{
int a
,b
,c
[10],d
,e
,f
;
for(a
=1;a
<=1000;a
++)
{
d
=0;f
=0;
for(b
=1;b
<a
;b
++)
{
if(a
%b
==0)
{
d
+=b
;
c
[f
++]=b
;
}
}
if(d
==a
)
{
printf("%d its factors are",a
);
for(e
=0;e
<f
;e
++) printf(" %d ",c
[e
]);
printf("\n");
}
}
}
可能第二种更简单吧,数组刚开始学,加油吧——19,11,3
转载请注明原文地址: https://mac.8miu.com/read-498300.html