2011年NOIP初赛普及组真题阅读程序写结果3:
#include<iostream> #include<cstring> using namespace std; const int SIZE = 100; int main() { int n,i,sum,x,a[SIZE]; cin>>n; memset(a,0,sizeof(a)); for(i=1;i<=n;i++){ cin>>x; a[x]++; } i=0; sum=0; while(sum<(n/2+1)){ i++; sum+=a[i]; } cout<<i<<endl; return 0; }
输入:11 45664332321
输出:______