Archives for 程序与算法

ZOJ 1049

C++代码 /*   Title: I Think I Need a Houseboat   Problem URL: http://acm.zju.edu.cn/show_problem.php?pid=1049   Author: Moqi   Date: 2007-12-31   Description:    */   #include <stdio.h>    #include <math.h>    int main()    {        int i, j, n;        float d, a, b;        scanf("%d", &n);        for(i = 1; i <= n; i++)        {            scanf("%f %f", &a, &b);            d = a * a + b * b;            j = d * 3.14159 / 100;            j = j + 1;            printf("Property %d: This property will begin eroding in year %d.\n", i, j);        }        printf("END OF OUTPUT.\n");        return 0;    }  

ZOJ 1048

  C++代码 /*   Title: Financial Management   Problem URL: http://acm.zju.edu.cn/show_problem.php?pid=1048   Author: Moqi   Date: 2007-12-31   Description:    */   #include <stdio.h>    int main()    {        int i;        float sum, one;        sum = 0;        for(i = 1; i <= 12; i++)        {            scanf("%f", &one);            sum += one;        }        sum /= 12.0;        printf("$%.2f\n", sum);        return 0;    } 

ZOJ 1034

简单题。 C++代码 /*   Title: Gridland   Problem URL: http://acm.zju.edu.cn/show_problem.php?pid=1037   Author: Moqi   Date: 2007-12-31   Description:    */   #include <stdio.h>    int main()    {        int n, i, a, b;        double sum;        scanf("%d", &n);        for(i = 1; i <= n; i++)        {            scanf("%d %d", &a, &b);            if ((a % 2 == 1) && (b % 2 == 1))                sum = 1.41428 – 1;            else               sum = 0;            sum += a * b;            printf("Scenario #%d:\n%.2f\n\n", i, sum);        }        return 0;    }