题样:
#include<stdio.h>
int isfactors(int a)//判断完数,返回1是,返回0不是
{
if(a==0)return 0;
int i=0;
int sum=0;
for(i=1;i<a;i++)
{
if(a%i==0)
{
sum=sum+i;
}
}
if(sum==a)return 1;
else return 0;
}
int main(){
int be=0;
int n=0,m=0,k=0,a[1000]={0};
scanf("%d %d",&m,&n);
int i=0,j=0,flag=0;
for(i=m;i<n;i++)
{
if(isfactors(i))
{
be=1;
a[k++]=i;
}
}
if(be==1)
{
for(i=0;i<k;i++)
{
flag=0;
if(i!=k-1)
{
printf("%d its factors are ",a[i]);
for(j=1;j<a[i];j++)
{
if(a[i]%j==0)
{
if(flag==0)
{
printf("%d",j);
flag=1;
}
else printf(",%d",j);
}
}
printf("\n");
}
else
{
printf("%d its factors are ",a[i]);
for(j=1;j<a[i];j++)
{
if(a[i]%j==0)
{
if(flag==0)
{
printf("%d",j);
flag=1;
}
else printf(",%d",j);
}
}
}
}
}
else printf("Not Found!");
return 0;
}