1003 Hangover

#include<iostream.h>

void main()
{
	double d , sum = 0.0 ;
	double i ;
	cin>>d;
	while( d != 0.00 )
	{
		for(i = 2 ; ; i++)
		{
			sum += (double)1/i;
			if(sum >= d ) 
			{
				cout<< i - 1 <<" card(s)"<<endl;
				break;
			}
		}
		sum = 0;
		cin>>d;
	}

}

你可能感兴趣的:(C++,c,C#)