Friday, May 3, 2019

CATCH THE SECOND

  • Problem Description

    A bag contains set of integers and it is discovered by Ram. There is sheet in that bag. The person who found the bag should find the second largest number from the set of numbers. If the rightly found the will get a gold.. If you wish get the prize you can also try...
  • CODING ARENA::
  • #include <stdio.h>
    int main()
    {
      int a,i,j,temp;
      scanf("%d",&a);
      int arr[a];
      for(i=0;i<a;i++)
        scanf("%d",&arr[i]);
      for(i=0;i<a;i++)
      {
        for(j=i;j<a;j++)
        {
          if(arr[i]<arr[j])
          {
            temp=arr[i];
            arr[i]=arr[j];
            arr[j]=temp;
          }
        }
      }
      printf("%d",arr[1]);
              

    return 0;
    }
  • Test Case 1

    Input (stdin)
    5

    5 3 1 2 6

    Expected Output
    5
  • Test Case 2

    Input (stdin)
    6

    16 58 2 1 6 99

    Expected Output
    58

No comments:

Post a Comment

Parity

Problem Description Ram and Sita playing the parity game. Two types of parity are there. One is odd parity and next is even parity. Ram will...