Friday, August 17, 2018

BUBBLY BUBBLY

  • Problem Description

    Reethu has various sized stones. His uncle told her to arrange the stones based on its size. Sanu knows how to arrange the stones. Reethu approaches sanu and ask her to help. Will you help reethu to do this work?
  • 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;
          }
        }
      }
      for(i=0;i<a;i++)
        printf("%d ",arr[i]);

    return 0;
    }
  • Test Case 1

    Input (stdin)
    5
    
    1 8 9 7 6
    
    
    Expected Output
    1 6 7 8 9
  • Test Case 2

    Input (stdin)
    4
    
    9 19 7 99
    
    
    Expected Output
    7 9 19 99

No comments:

Post a Comment