10个学生考完期末考试评卷完成后,A老师需要划出及格线,
// vector::pop_back #include <iostream> #include <vector> #include<string> using namespace std; int scoreLevel(int a[], int len){ int level; int temp; for(int i=0;i<10;i++){ for(int j=0;j<10-i-1;j++){ if(a[j]>a[j+1]){ temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; } } } cout<<a[0]<<endl; if(a[0]>60){ level = 60; } else{ level = a[3]; cout<<a[4]<<endl; for(int i=0;i<10;i++){ if(level%10==0){ break; } level--; } } return level; } int main() { int b; int a[10] = {61,51,49,3020,10,70,80,90,99}; b = scoreLevel(a,9); cout<<b<<endl; system("pause"); return 0; } //输入样例:61 51 49 3020 10 70 80 90 99 //输出样例:5010个学生考完期末考试评卷完成后,A老师需要划出及格线,要求如下:
(1) 及格线是10的倍数;
(2) 保证至少有60%的学生及格;
(3) 如果所有的学生都高于60分,则及格线为60分