Shell Sort Program in C++ With Source Code

#include<stdio.h>
#include<conio.h>

void main()
{
    int list[6]={10,9,8,7,6,5},i,dist,size=6,swap,temp;
    //list[10]={7,5,6,9,8,1,10,2,4,3}
    clrscr();

    dist=size/2;
    while(dist)
    {
        do
        {
            swap=0;
            for(i=0;i<(size-dist);i++)
            {
                if(list[i]>list[i+dist])
                {
                    temp=list[i];
                    list[i]=list[i+dist];
                    list[i+dist]=temp;
                    swap=1;
                }
            }
        }while(swap);
        dist=dist/2;
    }
    for(i=0;i<size;i++)
    {
        printf("The value of List[%d]:%d\n",i,list[i]);
    }
    getch();
}
Shell Sort Program in C++ With Source Code Shell Sort Program in C++ With Source Code Reviewed by Unknown on 5:49:00 PM Rating: 5

No comments:

Powered by Blogger.