C++ソートアルゴリズムの高速ソートアルゴリズム

1518 ワード

**
C++ソートアルゴリズムの高速ソートアルゴリズム
#include 
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

    void quicksort(int a[],int low,int high)
    {
        int i=low;
        int j=high;
        int num=low;
        while(iwhile(iif(a[j]break;
}
else
{
j--;
}
}
while(i<=j)
{
if(a[i]>a[num])
{
swap(a[i],a[num]);
num=i;
break;
}
else{
i++;
}
}
}
if(num-1>low)
{
quicksort(a,low,num-1);
}
if(high>num+1)
{
quicksort(a,num+1,high);
}
}
void swap(int a,int b)
{
int temp;
temp=a;
a=b;
b=temp;
}
int main(int argc, char** argv)
{
int total;
cout<<「データ を  してください:」;
cin>>total;
cout<<「データを  してください:」<int a[100];
for(int i=0;icin>>a[i];
}
quicksort(a,0,total-1);
for(int i=0;icout<" ";
}
cout<return 0;
}