两道简单题,此外,1049有网友给出的计算公式是 Z=3.14*(x*x+y*y)/100.0+1.0,可惜我不明白其原理
ZOJ1045 HangOver
复制代码
#include<iostream>
using namespace std;
int main()
{
double target,num,sum;
while(cin>>target&&target!=0.00)
{
sum = 0.0f;
num = 2;
while(sum<target)
{
sum += 1.0/num;
num++;
}
cout<<num-2<<" card(s)"<<endl;
}
return 0;
}
复制代码
ZOJ1048 Financial Management
复制代码
#include<iostream>
using namespace std;
int main()
{
double sum = 0.0f,average = 0.0f,num;
for (int i=0;i<12;++i)
{
cin>>num;
sum += num;
}
average = sum/12.0f;
cout<<"$"<<average<<endl;
return 0;
}
复制代码
本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2008/10/23/1318249.html,如需转载请自行联系原作者