POJ - 1005

#include 
#include 
#include 
#define PAI 3.14
int GetErodeYear(float X, float Y) {
    double area = 0.5 * PAI * (pow(X, 2) + pow(Y, 2));
    int year = area / 50;
    return (year + 1);
}

main() {
    int line_num;
    float *x;
    float *y;
    scanf("%d", &line_num);
    x = (float *)malloc(line_num * sizeof(float));
    y = (float *)malloc(line_num * sizeof(float));
    for (int i = 0; i < line_num; i++) {
        scanf("%f %f", x + i, y + i);
    }
    for (int i = 0; i < line_num; i++) {
        int result;
        result = GetErodeYear(*(x + i), *(y + i));
        printf("Property %0d: This property will begin eroding in year %0d.\n", (i + 1), result);
    }
    free(x);
    free(y);
    x = NULL;
    y = NULL;
    printf("END OF OUTPUT.");

}

你可能感兴趣的:(POJ - 1005)