| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
感觉对的代码AC不了,感觉错的代码却AC了,真郁闷这是AC的代码。
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int card[600];
double sum=0;
int temp=0;
int pretemp=0;
int i=2;
while(sum<5.21)
{
sum+=(1/double(i));
pretemp=temp+1;
temp=sum*100;
for(int j=pretemp;j<=temp;j++)
{
card[j]=i-1;
}
i++;
}
cin>>sum;
while(sum>0.001)
{
cout<<card[int(sum*100)]<<" card(s)"<<endl;
//感觉上面这句应该改成cout<<card[int(ceil(sum*100))]<<" card(s)"<<endl;
cin>>sum;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator