Friday, 4 November 2016

CODE FOR QUICKSORT IN DATA STRUCTURE

"Nice One Program"

#include<iostream.h>

#include<conio.h>



const int a=10;

void main()

{       clrscr();

  int array[a];

  cout<<"Enter the array :";

  for(int i=0;i<a;i++)

{  cin>>array[i];

  cout<<" ";


}

int k,c;

for(i=1;i<a;i++)

{

  k=array[i];

  c=i-1;


  while(array[c]>k&&c>=0)

  { array[c+1]=array[c];

    c--;

  }

  array[c+1]=k;


  }

     cout<<"\n\n";

  for(i=0;i<a;i++)

  cout<<array[i]<<" ";

getch();

}




No comments:

Post a Comment