POJ - 1003

简单题 c++练手

#include<iostream>
using namespace std;
int tiaohe(double n);
int main(){
    double num = 0;
    cin >> num;
    while (num != 0)
    {
        cout << tiaohe(num) << " card(s)" << endl;
        cin >> num;
    }
    return 0;
}
int tiaohe(double n){
    double sum = 0;
    int i = 1;
    do{
        i++;
        sum += 1.0 / i;
    } while (sum <= n);

    return i - 1;
}

posted @ 2013-10-19 17:54  Acmen  阅读(186)  评论(0编辑  收藏  举报