| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
数组开小了一次re 丢人啊!! 0ms~~~~#include<stdio.h>
typedef int type;
int partition(type *tt,int low,int high);
void Qsort(type *tt,int low,int high);//在头文件下;
int partition(type *tt,int low,int high)
{
type pivotkey;
pivotkey=tt[low];
while(low<high){
while(low<high && tt[high]>=pivotkey) high--;
tt[low]=tt[high];
while(low<high && tt[low]<=pivotkey) low++;
tt[high]=tt[low];
}
tt[low]=pivotkey;
return low;
}
void Qsort(type *tt,int low,int high)
{
int pivot;
if(low<high){
pivot=partition(tt,low,high);
Qsort(tt,low,pivot-1);
Qsort(tt,pivot+1,high);
}
}
int main()
{
int i,tt[1000],n;
int av,sum;
while(scanf("%d",&n),n!=0)
{
for(i=0;i<n;i++)
scanf("%d",&tt[i]);
sum=0;
av=0;
Qsort(tt,0,n-1);//将n个数排序在主函数中;
for(i=1;i<n-1;i++)
sum=sum+tt[i];
av=sum/(n-2);
printf("%d\n",av);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator