Sunday, April 24, 2016

UVA 11764: Jumping Mario -Solution

Unknown
#include <stdio.h>
int main ()
{
    int t, c=1, n,h[50],hj,lj,i,j;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d",&n);
        hj=0;
        lj=0;
        for (i=0;i<n;i++)
        {
            scanf("%d",&h[i]);
            j=1;
            while (i>0&&j--)
            {
                if (h[i-1]<h[i]) hj++;
                else if  (h[i-1]>h[i]) lj++;
                continue;
            }
        }
        printf("Case %d: %d %d\n",c++,hj,lj);
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,