首页 > 其他 > 详细

【水滴石穿】1003

时间:2019-12-01 19:47:48      阅读:68      评论:0      收藏:0      [点我收藏+]

2019-11-28

1003 简化代码,也别把问题想复杂

#include <stdio.h>
#include <stdlib.h>


int main()
{
    float c,sum,base;
    int count;
    scanf("%f",&c);
    while(c!=0.00)
    {
        base=2;
        sum=1/base;
        count=1;
        while(sum<c)
        {
            base++;
            sum+=1/base;
            count++;
        }
        printf("%d card(s)\n",count);
        scanf("%f",&c);
    }
    return 0;
}

 

【水滴石穿】1003

原文:https://www.cnblogs.com/calm-blogme/p/11966987.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!