fork download
  1. #include<iostream.h>
  2. #include<conio.h>
  3.  
  4. int Partition(int a[], int beg, int end) //Function to Find Pivot Point
  5. {
  6. int p=beg, pivot=a[beg], loc;
  7.  
  8. for(loc=beg+1;loc<=end;loc++)
  9. {
  10. if(pivot>a[loc])
  11. {
  12. a[p]=a[loc];
  13. a[loc]=a[p+1];
  14. a[p+1]=pivot;
  15.  
  16. p=p+1;
  17. }
  18. }
  19. return p;
  20. }
  21.  
  22.  
  23. void QuickSort(int a[], int beg, int end)
  24. {
  25. if(beg<end)
  26. {
  27. int p=Partition(a,beg,end); //Calling Procedure to Find Pivot
  28.  
  29. QuickSort(a,beg,p-1); //Calls Itself (Recursion)
  30. QuickSort(a,p+1,end); //Calls Itself (Recursion)
  31. }
  32. }
  33.  
  34.  
  35. void main()
  36. {
  37. clrscr();
  38. int a[100],i,n,beg,end;
  39.  
  40. cout<<"\n------- QUICK SORT -------\n\n";
  41. cout<<"Enter the No. of Elements : ";
  42. cin>>n;
  43.  
  44. for(i=1;i<=n;i++)
  45. {
  46. cin>>a[i];
  47. }
  48. beg=1;
  49. end=n;
  50.  
  51. QuickSort(a,beg,end); //Calling of QuickSort Function
  52.  
  53. cout<<;"\nAfter Sorting : \n";
  54. for(i=1;i<=n;i++)
  55. {
  56. cout<<a[i]<<endl;
  57. }
  58. getch();
  59. }
  60.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:21: fatal error: iostream.h: No such file or directory
compilation terminated.
stdout
Standard output is empty