19、
#include <stdio.h>
void main()
{
int i, j, sum;
for (i = 2; i <= 1000; i++)
{
sum = 1;
for (j = 2; j <= i / 2; j++)
if (i%j == 0)
sum += j;
if (sum == i)
{
printf("%d its factors are 1,", i);
for (j = 2; j <= i / 2; j++)
if (i%j == 0)
printf("%d,", j);
printf("\n");
}
}
}
20、
#include <stdio.h>
void main()
{
float sn = 100.0, hn = sn / 2;
int n;
for (n = 2; n <= 10; n++)
{
sn = sn + 2 * hn;
hn /= 2;
}
printf("the total of road is %f\n", sn);
printf("the tenth is %f neter\n", hn);
}
21、
#include <stdio.h>
void main()
{
int day, x1, x2;
day = 9;
x2 = 1;
while (day > 0)
{
x1 = (x2 + 1) * 2;
x2 = x1;
day--;
}
printf("the total is %d\n", x1);
}