Saturday, October 22, 2011

solution of balagurusamy of chapter 8.5

#include<stdio.h>
#include<string.h>

int main()
{
    int i,j,n;
    char s[20],temp;
    scanf("%s",s);
    n=strlen(s)-1;
    /*---BUBBLE SORT---*/
    for(i=0; i<n; i++)
        for(j=0;j<n-i;j++)
            if(s[j]>=s[j+1])
            {
                temp = s[j];
                s[j] = s[j+1];
                s[j+1] = temp;
            }
    printf("%s",s);
    return 0;
}

No comments:

Post a Comment