Friday, May 3, 2019

ASCCENDING STRING

  • Problem Description

    Code for Sort given string in ascending order
  • CODING ARENA
  • #include <stdio.h>
    #include<string.h>
    int main()
    {
      char str[100],temp;
      int i,j;
      scanf("%s",str);
      for(i=0;str[i];i++)
      {
        for(j=i+1;str[j];j++)
        {
          if(str[j]<str[i])
          {
            temp=str[j];
            str[j]=str[i];
            str[i]=temp;
          }
        }
      }
      printf("%s",str);

    return 0;
    }
  • Test Case 1

    Input (stdin)
    sample

    Expected Output
    aelmps
  • Test Case 2

    Input (stdin)
    string

    Expected Output
    ginrst

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...