//求最大卡片数
//注意精度问题,否则题目会出错
#include <iostream>
using namespace std;
int main()
{
 //使用double类型,如果使用float类型精度不够,会出错
 double data;
 cin>>data;
 while(data!=0.00 && data>=0.01 && data<=5.20)
 {
  double sum=0;
  int n=2;
  while(sum<data)
  {
   sum = sum+1.00/n;
   n++;
  }
  cout<<n-2<<" card(s)"<<endl;
  cin>>data;
 }
 return 0;
}

相关文章:

  • 2021-07-31
  • 2021-04-27
  • 2021-04-26
  • 2021-07-12
  • 2021-09-26
  • 2021-06-26
  • 2021-04-18
  • 2021-10-12
猜你喜欢
  • 2021-12-10
  • 2022-01-10
  • 2021-12-14
  • 2021-04-04
  • 2021-08-19
  • 2021-05-05
  • 2021-11-13
相关资源
相似解决方案