Saturday, May 6, 2017

uva problem-12709 falling ant


problem link:

discussion:  Just compare the value  of H if H is large then downward acceleration also large..
if H and large H is equal then compare the volume of them the large volume should assign to the large volume.

here are the code, before see the code try yourself first. otherwise you can't develop in programmin


#define g 9.80665
#include<stdio.h>

int main()
{
    int l,w,h,n,v,i,temp;
    double da;
    while(scanf("%d",&n)==1)
    {
        int hv=0,hh=0;
        double hd=0.0;
        if(n==0)
            break;
            for(i=1;i<=n;i++)
            {
        scanf("%d %d %d",&l,&w,&h);


        v=l*w*h;
        {
            if(h>hh||(h==hh&&v>hv))
            {

                hv=v;
                hh=h;
            }
            }
        }

        printf("%d\n",hv);

    }
    return 0;
}

No comments:

Post a Comment