参考:https://blog.csdn.net/neoxuhaotian/article/details/6112147
https://blog.csdn.net/lionel_d/article/details/44198125
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #define pi 3.1415926 6 using namespace std; 7 int main() 8 { 9 int t; 10 while (cin>>t) 11 { 12 for (int j=1;j<=t;j++) 13 { 14 float d,x,y; 15 cin>>x>>y; 16 d=sqrt(x*x+y*y); 17 for (int i=1;;i++) 18 { 19 float s=i*100.0; 20 float r=sqrt(s/pi); 21 if (d<=r) 22 { 23 cout<<"Property "<<j<<": This property will begin eroding in year "<<i<<'.'<<endl; 24 break; 25 } 26 } 27 } 28 cout<<"END OF OUTPUT."<<endl;//注意此句位置,不要误放入j循环内! 29 } 30 31 return 0; 32 }