出售金鱼

#include <stdio.h>

int main()
{
int sum = 0;
int i = 0;
int flag = 0;
double tmp = 0;

for(sum = 11; sum <= 1000; sum++)
{
tmp = (double)sum;
for(i = 1; i <= 4; i++)
{
tmp = tmp - (tmp + 1) / (i + 1);
}
if(tmp < 11.000001 && tmp > 10.999999)
{
flag = 1;
break;
}
}
if(flag)
printf("金鱼总数为%d\n", sum);
else
printf("error\n");
return 0;
}

posted @ 2023-05-24 13:57  不会JAVA的小袁  阅读(7)  评论(0编辑  收藏  举报