马彦宸 • 3年前
#include<bits/stdc++.h>
using namespace std;
double pi = 3.1415;
int c(float x, float y)
{
double r = sqrt(x*x + y*y);
double s = pi * r * r / 2;
int numYear = (int)(s / 50);
return numYear;
}
int main()
{
int n;
cin >> n;
double a[n*2];
for(int i=0;i<2*n;i++)
cin>>a[i];
int y[n];
for(int i = 1; i <= n; i++)
{
y[i] = c(a[i], a[i+1]);
cout << "Property "<<i<<": This property will begin eroding in year "<< y[i] << "." << endl;
}
cout << "END OF OUTPUT." << endl;
}
评论: