用c语言编码1000一杯的所有完数,并按下面格式输出其因子:6 its factors are 1,2,3

2024-12-04 00:11:08
推荐回答(1个)
回答1:

int m, i, s;
for (m = 1; m <= 1000; m++)
{
s = 0;
for (i = 1; i < m; i++)
if (m%i == 0)
s = s + i;
if (s == m)
{
printf("\n%d=", s);
for (i = 1; i < m; i++)
if (m%i == 0)
{
printf("%d", i); printf("+");
}
}
}
给你个对的 自己调调,看看自己哪里错了