标签:name 中间 i++ for count ccf sort iostream printf
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
int i,j,count1 = 0,count2 = 0;
for(i=0;i<n;i++) cin>>a[i];
sort(a,a+n);
for(i=0;i<n;i++){
if(a[i]>a[n/2]) count1++;
else if(a[i]<a[n/2])count2++;
}
if(count1 == count2) printf("%d",a[n/2]);
else printf("-1");
return 0;
}
标签:name 中间 i++ for count ccf sort iostream printf
原文地址:http://www.cnblogs.com/whitehouse2016/p/6532743.html