简单题
特别基本的sort排序,注意cmp函数的写法
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef struct{
int MakeMilk;
int num;
}COW;
COW cow[10005];
bool cmp(COW A,COW B);
int main(){
int n;
while (scanf("%d",&n)!=EOF){
for(int i=1;i<=n;i++){
cin>>cow[i].MakeMilk;
cow[i].num=i;
}
sort(cow+1,cow+n+1,cmp);
cout<<cow[(n+1)/2].MakeMilk;
}
return 0;
}
bool cmp(COW A,COW B){
if(A.MakeMilk<B.MakeMilk)
return true;
if(A.MakeMilk==B.MakeMilk&&A.num>B.num)
return true;
return false;
}