题目
样例
参考代码
import java. util. Scanner;
public class Main {
public static void main ( String[ ] args) {
Scanner sc= new Scanner ( System. in) ;
int n= sc. nextInt ( ) ;
int a= 0 ;
int b= 0 ;
int c= 0 ;
int d= 0 ;
int e= 0 ;
int ar[ ] = new int [ 1001 ] ;
int br[ ] = new int [ 1001 ] ;
int cr[ ] = new int [ 1001 ] ;
int dr[ ] = new int [ 1001 ] ;
int er[ ] = new int [ 1001 ] ;
while ( n-- > 0 ) {
int amount= sc. nextInt ( ) ;
if ( amount>= 90 )
ar[ a++ ] = amount;
if ( amount>= 80 && amount< 90 )
br[ b++ ] = amount;
if ( amount>= 70 && amount< 80 )
cr[ c++ ] = amount;
if ( amount>= 60 && amount< 70 )
dr[ d++ ] = amount;
if ( amount< 60 )
er[ e++ ] = amount;
}
int max= Math. max ( a, b) ;
int max2= Math. max ( max, c) ;
int max3= Math. max ( max2, d) ;
int remax= Math. max ( max3, e) ;
System. out. print ( a) ;
System. out. print ( " " ) ;
System. out. print ( b) ;
System. out. print ( " " ) ;
System. out. print ( c) ;
System. out. print ( " " ) ;
System. out. print ( d) ;
System. out. print ( " " ) ;
System. out. print ( e) ;
System. out. println ( ) ;
System. out. println ( remax) ;
if ( remax== a)
sort ( ar, a) ;
if ( remax== b)
sort ( br, b) ;
if ( remax== c)
sort ( cr, c) ;
if ( remax== d)
sort ( dr, d) ;
if ( remax== e)
sort ( er, e) ;
}
static void sort ( int arr[ ] , int n) {
for ( int i= 0 ; i< n- 1 ; i++ ) {
for ( int j= 0 ; j< n- 1 - i; j++ ) {
if ( arr[ j] < arr[ j+ 1 ] )
{
int temp= arr[ j] ;
arr[ j] = arr[ j+ 1 ] ;
arr[ j+ 1 ] = temp;
}
}
}
for ( int i= 0 ; i< n; i++ ) {
System. out. print ( arr[ i] ) ;
if ( i!= n- 1 )
System. out. print ( " " ) ;
}
}
}