//北京理工大学上机3
#include <iostream>
using namespace std;
typedef struct{
char name[20];
float score1;
float score2;
float score3;
int total;
}Student;
void swap(Student s[],int i,int j){
Student temp=s[i];
s[i]=s[j];
s[j]=temp;
}
void find_fail(Student s[],int n){
for(int i=0;i<n;i++){
if(s[i].score1<60||s[i].score2<60||s[i].score3<60){
cout<<"*["<<s[i].name<<"] ";
cout<<s[i].score1<<" ";
cout<<s[i].score2<<" ";
cout<<s[i].score3<<endl;
}
}
cout<<endl;
}
void printByAverage(Student s[],int n){
for(int i=0;i<n-1;i++)
for(int j=n-1;j>i;j--)
if(s[j-1].total>s[j].total)
swap(s,j-1,j);
for(int k=n-1;k>=0;k--){
cout<<s[k].name<<" ";
cout<<s[k].score1<<" ";
cout<<s[k].score2<<" ";
cout<<s[k].score3<<endl;
}
}
int main(){
cout<<"please input student number"<<endl;
int n=0;
cin>>n;
Student s[100];
cout<<"please input student's name,score1,score2,score3"<<endl;
for(int i=0;i<n;i++){
cin>>s[i].name;
cin>>s[i].score1;
cin>>s[i].score2;
cin>>s[i].score3;
cin>>s[i].total;
}
find_fail(s,n);
printByAverage(s,n);
return 0;
}
北京理工大学 计算机考研 上机考试 真题分析和经验总结.zip
版权申诉
69 浏览量
2024-04-01
16:39:03
上传
评论
收藏 3KB ZIP 举报
小码蚁.
- 粉丝: 2520
- 资源: 4057
最新资源
- 部署yolov8的tensorrt模型支持检测分割姿态估计的C++源码+部署步骤.zip
- 以简单、易用、高性能为目标、开源的时序数据库,支持Linux及Windows, Time Series Database.zip
- python-leetcode面试题解之第198题打家劫舍-题解.zip
- python-leetcode面试题解之第191题位1的个数-题解.zip
- python-leetcode面试题解之第186题反转字符串中的单词II-题解.zip
- 一个基于python的web后端高性能开发框架,下载可用
- python-leetcode面试题解之第179题最大数-题解.zip
- python-leetcode面试题解之第170题两数之和III数据结构设计-题解.zip
- python-leetcode面试题解之第168题Excel表列名称-题解.zip
- python-leetcode面试题解之第167题两数之和II输入有序数组-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈