Saturday, May 6, 2017

12614-Earn for future uva problem

problem link:

Discussion: In this problem you just have to find the maximum value of card..and then print it..don't panic with bitwise operator.

here the code..at first try yourself.if you can't then only see the code.otherwise you can't develop yourself in programming.


#include<stdio.h>
int main()
{
    int t,k,n,ara[40],i,j,temp;
    scanf("%d",&t);
    for(k=1;k<=t;k++)
    {
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
            scanf("%d",&ara[i]);
        }
        for(i=0;i<n-1;i++)
        {
            for(j=0;j<n-1-i;j++)
            {
                if(ara[j+1]>ara[j])
                {
                    temp=ara[j+1];
                    ara[j+1]=ara[j];
                    ara[j]=temp;
                }
            }

        }

 printf("Case %d: %d\n",k,ara[0]);
    }
     return  0;
}

No comments:

Post a Comment