代码:
//============================================================================ // Name : 1005.cpp // Author : // Version : // Copyright : Your copyright notice // Description : 1005 in C++, Ansi-style //============================================================================ #include <iostream> #include <math.h> #define PI 3.1415926 using namespace std; int main() { int n=0; float array[1000]={0}; float numa,numb; cin>>n; int i=0; for(;i!=n;i++) { cin>>numa>>numb; // float len=hypot(numa,numb); array[i]=(numa*numa+numb*numb)*PI/2; } i=0; for(;i!=n;i++) { int flag=1; int temp=array[i]/50; if((array[i]-temp*50)==0) { flag=0; } cout<<"Property "<<i+1<<": This property will begin eroding in year "<<temp+flag<<"."<<endl; } cout<<"END OF OUTPUT."<<endl; return 0; }
比较简单.
参考译文:http://wenku.baidu.com/view/ba07020a763231126edb11ce.html
问题:
北大acm,不支持 math.h中的函数.使用hypot函数出错.
格式很重要,第一次漏了一个 '.'.就直接被判WA了.