Chinaunix首页 | 论坛 | 博客
  • 博客访问: 436568
  • 博文数量: 103
  • 博客积分: 5010
  • 博客等级: 大校
  • 技术积分: 971
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-11 17:22
文章分类
文章存档

2008年(77)

2007年(26)

我的朋友

分类: C/C++

2008-03-10 22:30:42

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

int main(int argc, char **argv)
{
        float f;
        unsigned int n, i = 0, times = 0;
        float temp;
        char buff[20][20];

        while(1){
                scanf("%f", &f);
                times += 1;

                n = 1;
                temp = 1.00/(n+1);

                if(f == 0.00){
                        break;
                }
                else if((f < 0.01) || (f > 5.20)){
                        continue;
                }

                while(f > temp){
                        n++;
                        temp += 1.00/(n+1);
                }

                snprintf(buff[i], 20, "%d card(s)", n);
                i++;
        }
                buff[times-1][0] = '\0';

                for(i = 0; i < times-1; i++){
                        printf("%s\n", buff[i]);
                }

        exit(0);
}

阅读(621) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~