参考代码:
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<int> vec[5]; //五个等级段的人数 for(int i=0;i<n;i++){ int x; cin>>x; if(x>=90){ vec[0].push_back(x); }else if(x>=80){ vec[1].push_back(x); }else if(x>=70){ vec[2].push_back(x); }else if(x>=60){ vec[3].push_back(x); }else{ vec[4].push_back(x); } } int m=0,index=-1; for(int j=0;j<5;j++){ cout<<vec[j].size()<<" "; if(m<vec[j].size()){ m=vec[j].size(); index=j; } } cout<<endl<<m<<endl; //greater降序 sort(vec[index].begin(),vec[index].end(),greater<int>()); for(int i=0;i<vec[index].size();i++){ cout<<vec[index][i]<<" "; } return 0; }
0.0分
0 人评分
【明明的随机数】 (C语言代码)浏览:699 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:846 |
C语言考试练习题_保留字母 (C语言代码)浏览:723 |
C二级辅导-进制转换 (C语言代码)浏览:544 |
大神老白 (C语言代码)浏览:660 |
C语言训练-字符串正反连接 (C语言代码)浏览:655 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:1545 |
输出正反三角形 (C语言代码)浏览:853 |
求组合数 (C语言代码)浏览:1195 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:855 |