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.

Comments

Leave a Reply

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

one × three =

coder by Gleentech
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.