三道水题

做了三道水题,练手。水题也要细心

POJ 1004:

/*Accepted 180K 0MS C++ 187B 2012-04-26 16:48:20 */

#include<cstdio>



double a, sum;



int main()

{

    sum = 0;

    for( int i = 0; i < 12; i ++)

    {

        scanf( "%lf", &a);

        sum += a;

    }

    printf( "$%.2lf\n", sum / 12);

    return 0;

}

POJ 2027

/*Accepted 164K 0MS C++ 223B 2012-04-26 16:54:03 */

#include<cstdio>



int main()

{

    int x, y;

    int t;

    scanf( "%d", &t);

    while( t --)

    {

        scanf( "%d%d", &x, &y);

         if( x < y)

            printf( "NO BRAINS\n");

        else

            printf( "MMM BRAINS\n");

    }

    return 0;

}

POJ 2017

/*Accepted 164K 0MS C++ 321B 2012-04-26 17:07:30 */

#include<cstdio>



int main()

{

    int n, a, b, c, d, sum;

    while( scanf( "%d", &n) != EOF)

    {

        if( n == -1) break;

        scanf( "%d%d", &a, &b);

        sum = a * b;

        for( int i = 1; i < n; i ++)

        {

            scanf( "%d%d", &c, &d);

            sum += c * ( d - b);

            b = d;

        }

        printf( "%d miles\n", sum);

    }

    return 0;

}

 

你可能感兴趣的:(水题)