昨天的小尾巴,现在解决掉。。。。
#include<stdio.h>
int partsort(int a[],int low,int high)
{
int key;
key=a[low];
while(low<high)
{
while(low<high&&a[high]>=key)
high--;
if(low<high)
a[low++]=a[high];
while(low<high&&a[low]<=key)
low++;
if(low<high)
a[high--]=a[low];
}
a[low]=key;
return low;
}
void quicksort(int a[],int s,int t)
{
int loc;
if(s<t)
{
loc=partsort(a,s,t);
quicksort(a,s,loc-1);
quicksort(a,loc+1,t);
}
}
int a[20005];
int main()
{
int i,k,n,t,sum;
scanf("%d",&t);
while(t--)
{
sum=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
quicksort(a,0,n-1);
k=n%3;
for(i=k;i<n;i+=3)
sum+=a[i];
printf("%d\n",sum);
}
return 0;
}