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 |
我的程序为什么是wrong answer 啊?恳请高手赐教啊!我的思路是PI/2*(Rn*Rn)-PI/2*(Rn-1*Rn-1)=50;然后迭代,Rn=sqrt(100/PI+Rn-1*Rn-1); 当Rn>d是就结束了。我的代码中now next分别代表Rn Rn-1 运行结果没错啊!我的很多同学不知道我的程序为什么错了!我大二。谢谢指点啊! #include<iostream> #include<cmath> #define PI 3.1415926 using namespace std; int main() { float next,num=0,now,x,y,d; int T,year; next=now=0; cin>>T; do { ++num; year=1; cin>>x>>y; d=sqrt(x*x+y*y); while(next<d) { next=sqrt(100/PI+now*now); if(next>d) break; else ++year; now=next; } cout<<"Property "<<num<<": This property will begin eroding in year "<<year<<"."<<endl; }while(--T); cout<<"END OF OUTPUT."<<endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator