#include <stdio.h> int main(){ float c; while(scanf("%f",&c) && c){ int a=1,num=0; float sum=0, b=0.5; do{ sum = sum+b; num++;a++; b = 1.00/(a+1); }while (sum<c&&num<276); printf("%d%s\n",num," card(s)"); } return 0; }
poj-1003
最新推荐文章于 2021-07-11 11:04:34 发布
本文展示了一个使用C语言编写的程序,该程序通过不断累加逐渐减小的浮点数直到达到用户输入的目标值为止,并输出所需累加次数。程序采用do-while循环结构,确保至少执行一次循环。
175

被折叠的 条评论
为什么被折叠?



