J
Jason Felix
#include<iostream>
#include<cstring>
using namespace std;
void quicksort(char *num,int len);
void qs(char *num,int left,int right);
int main()
{
char num[]="3,7,3,6,7,9,5,4,1,7,8,90,5,334,54,213,78";
cout<<"Original: "<<num<<"\n";
cout<<"sorting......"<<"\n";
quicksort(num,numlen(num));
cout<<"sorted: "<<num<<"\n";
return 0;
}
void quicksort(char *num,int len)
{
qs(num,0,len-1);
}
void qs(char *num,int left,int right)
{
int i,j;
char x,y;
i=left;j=right;
x=num[(left+right)/2];
do{
while((num<x)&&(i<right))i++;
while((y>num[j])&&(j>left))j--;
if(i<=j){
y=num;
num=num[j];
num[j]=y;
i++;j--;
}
}while(i<=j);
}
#include<cstring>
using namespace std;
void quicksort(char *num,int len);
void qs(char *num,int left,int right);
int main()
{
char num[]="3,7,3,6,7,9,5,4,1,7,8,90,5,334,54,213,78";
cout<<"Original: "<<num<<"\n";
cout<<"sorting......"<<"\n";
quicksort(num,numlen(num));
cout<<"sorted: "<<num<<"\n";
return 0;
}
void quicksort(char *num,int len)
{
qs(num,0,len-1);
}
void qs(char *num,int left,int right)
{
int i,j;
char x,y;
i=left;j=right;
x=num[(left+right)/2];
do{
while((num<x)&&(i<right))i++;
while((y>num[j])&&(j>left))j--;
if(i<=j){
y=num;
num=num[j];
num[j]=y;
i++;j--;
}
}while(i<=j);
}