#include <iostream>
#include <cstdlib>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
int n,b,c,i,d=0,e=0,f=0;
cin>>n;
int a[n];
for(i=0;i<n;i++){
cin>>a[i];}
sort(a,a+n);
for(i=0;i<n;i++){
cout<<a[i]<<" ";}
cout<<endl;
if(a[n-1]<60)
{
cout<<a[0]<<endl;
cout<<"worst case"<<endl;
}
else if(a[0]>=60){
cout<<"best case"<<endl;
cout<<a[0]<<endl;
}
else
{
for(i=0;i<n;i++){
while(a[i]>=60){
b=a[i-1];
c=a[i];
d=1;
break;
}
if(d==1)
break;
}
cout<<a[i-1]<<endl;
cout<<a[i]<<endl;
}
//system("pause");
return 0;
}
#include
#include
#include
#include
#include
#include
using namespace std;
int main()
{
int n,b,c,i,d=0,e=0,f=0;
cin>>n;
int a[n];
for(i=0;i<n;i++){
cin>>a[i];}
sort(a,a+n);
for(i=0;i<n;i++){
cout<<a[i]<<" ";}
cout<<endl;
if(a[n-1]<60)
{
cout<<a[0]<<endl;
cout<<"worst case"<<endl;
}
else if(a[0]>=60){
cout<<"best case"<<endl;
cout<<a[0]<<endl;
}
else
{
for(i=0;i<n;i++){
while(a[i]>=60){
b=a[i-1];
c=a[i];
d=1;
break;
}
if(d==1)
break;
}
cout<<a[i-1]<<endl;
cout<<a[i]<<endl;
}
//system("pause");
return 0;
}
第二行印出最高不及格分數,但是當所有人都不及格時,你卻輸出成績最低的,這裡改掉就可以了