第七次作业
作者:互联网
由于自己上课没注意听,下课后也没多做功课,所以当看到这道题的时候,不知道怎么下手,之后就看了书上的及知识点,然后试着做了一下,但还是有问题,就问了别人,但第六题还是没做出来
#include<stdio.h>
int main(void)
{
int factorsum(int number);
int m,n,x,s;
scanf("%d%d",&m,&n);
printf("enter two number:1<=m,n<=1000\n");
for(x=m;x<=n;x++)
{
s=x;
if(factorsum(s)==s)
printf("%d\n",s);
}
return 0;
}
int factorsum(int number)
{
int i,sum;
for(i=1,sum=0;i<number;i++)
if(number%i==0)
sum=sum+i;
return sum;
}
int main(void)
{
int factorsum(int number);
int m,n,x,s;
scanf("%d%d",&m,&n);
printf("enter two number:1<=m,n<=1000\n");
for(x=m;x<=n;x++)
{
s=x;
if(factorsum(s)==s)
printf("%d\n",s);
}
return 0;
}
int factorsum(int number)
{
int i,sum;
for(i=1,sum=0;i<number;i++)
if(number%i==0)
sum=sum+i;
return sum;
}
标签:return,int,sum,printf,作业,number,第七次,factorsum 来源: https://www.cnblogs.com/LXH614/p/10936669.html