本题也没什么难度,解决思想就是根据给定的(x, y)坐标值,计算半圆的面积,然后除以50,向上取整。
#include<stdio.h>
#include<math.h>#define PI 3.141592654
int main(int argc, char const *argv[])
{
int n ;
double x, y ;
double area ;
int count = 1 ;
FILE *fp = fopen( "in.txt", "r" ) ;
fscanf( fp, "%d", &n ) ;
// scanf( "%d", &n ) ;
while( n-- )
{
fscanf( fp, "%lf %lf", &x, &y ) ;
// scanf( "%lf %lf", &x, &y ) ;
area = 0.5 * PI * ( x * x + y * y ) ;
// printf("area = %.2lf\n", area);
printf("Property %d: This property will begin eroding in year %g.\n", count++, ceil(area / 50));
}
printf("END OF OUTPUT.\n");
return 0;
}