程序代码:
# include <stdio.h>
int main (void)
{
int w1, w2;
int i , j, k, sum=0;
printf("请输入一个范围:");
scanf ("%d %d", &w1, &w2);
for (i= w1; i<=w2; ++i)
{
for (j=1; j<i; ++j)
{
if (i%j == 0)
{
sum = sum + j;
}
}
if (sum == i)
{
printf("%d ", i);
}
sum = 0;
}
return 0;
}