第二次实训作业

package classwork;
import java.util.*;

public class sore {

/**
 * @param args
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub
    int StudentSore[];
    int i,Maxsore,Minsore;
    StudentSore = new int[4];
    Scanner Student = new Scanner(System.in);
    System.out.println("请输入四个学生的成绩:");
    for(i=0;i<4;i++){
        StudentSore[i] = Student.nextInt();
    
    }
    for(i=0;i<4;i++){
        System.out.println(StudentSore[i]);
    
    }
    for(i=3;i>-1;i--){
        System.out.println(StudentSore[i]);
            
    }
    for(i=0,Maxsore=StudentSore[0];i<4;i++){
        if(StudentSore[i]>Maxsore) Maxsore=StudentSore[i];
    }
    for(i=0,Minsore=StudentSore[0];i<4;i++){
        if(StudentSore[i]<Minsore) Minsore=StudentSore[i];
    }
    System.out.println("最高分为:"+Maxsore);
    System.out.println("最低分为:"+Minsore);
}

}

猜你喜欢

转载自www.cnblogs.com/201801420303oyw/p/10682578.html