主题:[讨论]新手求助 POJ1005
请问我的代码哪儿出错了啊?可以得出结果啦?谢谢指点啊!
#include<iostream>
#include<cmath>
#define PI 3.1415926
using namespace std;
int main()
{
float next,num=0,now,x,y,year,d;
int T;
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;
}
#include<iostream>
#include<cmath>
#define PI 3.1415926
using namespace std;
int main()
{
float next,num=0,now,x,y,year,d;
int T;
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;
}