these snippet below will work only for 5 numbers.
Selection sorting
Bubble Sorting
main()
{
int num[5]={5,2,4,1,3};
int c,d,t;
clrscr();
for(c=0;c<4;c++)
{
for(d=c+1;d<5;d++)
{
if(num[c]>num[d])
{
t=num[c];
num[c]=num[d];
num[d]=t;
}
}
}
for(c=0;c<5;++c)
printf("%d",num[c]);
getch();
}
Insertion sorting
0 comments:
Post a Comment