【POJ】1005. I Think I Need a Houseboat

来源:互联网 发布:淘宝卖的竹节棉 编辑:程序博客网 时间:2024/05/03 17:59
#include <stdio.h>#include <cmath>#define pi 3.1415926536using namespace std;int main(int argc, char *argv[]) {    int n;    float x, y;    scanf("%d", &n);    float preR2, R2;    int i;    int count = 1;    while (n-- > 0) {        scanf("%f %f", &x, &y);        for (i = 1; ; i++) {            if (i == 1) {                R2 = (100 / pi);            } else {                R2 = (100 / pi + preR2);            }            if (pow(x, 2) + pow(y, 2) < R2) break;            preR2 = R2;        }        printf("Property %d: This property will begin eroding in year %d.\n", count, i);        count++;    }    printf("END OF OUTPUT.\n");    return 0;}
0 0
原创粉丝点击