C – Bubble Sort

Hello Everyone!

One of these days I decided to solve a sort of data with C, using c99.

I tried to solve it as a issue for my filesystem implementations.

&lt bubble (item,count) char *item; int count; { register int a,b; register char t; for(a=1;a=a;–b){ if(item[b-1]> item[b]){ /* elements to exchange */ t = item[b-1]; item[b-1] = item[b]; item[b]=t; } } }

main() /* main function of the bubble sort */ { char s[80]; int count; sprintf(“enter a string:”); gets(s); count = strlen(s); bubble(s,count); printf(“the sorted string is : %s”, s); return 0; }

As I did the workaround.

Leave a Reply

Your email address will not be published. Required fields are marked *

3 × 4 =