参考代码:
#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语言程序设计教程(第三版)课后习题6.3 (Java代码)浏览:687 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:1055 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:570 |
C语言训练-排序问题<1> (C++代码)浏览:624 |
【金明的预算方案】 (C++代码)浏览:869 |
C语言程序设计教程(第三版)课后习题9.2 (C语言代码)浏览:567 |
最小公倍数 (C语言代码)浏览:1086 |
C语言程序设计教程(第三版)课后习题9.10 (C语言代码)浏览:859 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:556 |
1054题解浏览:508 |