快速排序:
void sort(int *a,int left,int right)
{
if(left>=right)
{
return ;
}
int i=left;
int j=right;
int key=a[left];
while(i<j)
{
while (i<j&&key<=a[j])
{
j--;
}
a[i]=a[j];
while (i<j&&key>=a[j])
{
i++;
}
a[j]=a[i];
}
a[i]=key;
sort(a,left,i-1);
sort(a,i+1,right);
}
二分法匹配:
int low,high,mid;
low=0,high=n-1,mid=(n-1)/2;
while(low<high&&a[mid]!=b[j])
{
if(a[mid]<b[j])
low=mid+1;
else if(a[mid]>b[j])
high=mid-1;
mid=(low+high)/2;
}
if(a[mid]==b[j])
t=1;