Problem Description
Code for Sort given string in ascending orderTest Case 1
Input (stdin)sample
Expected Outputaelmps
Test Case 2
Input (stdin)string
Expected Outputginrst
Program
#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; }
No comments:
Post a Comment
Note: only a member of this blog may post a comment.