java中编程输入10位同学的成绩,输出最高分?
1个回答
展开全部
package com;
import java.util.Scanner;
public class ArrayTest {
public static void main(String[] args) {
int[]array = new int[10];
int temp = 0;
System.out.println("请输入成绩:");
for(int i =0;i<array.length;i++){
Scanner sc =new Scanner(System.in);
array[i] = sc.nextInt();
}
for(int x = 0;x<array.length-1;x++){
for(int y = 0;y<array.length-x-1;y++){
if(array[y]>array[y+1]) {
temp = array[y];
array[y] = array[y+1];
array[y+1]=temp;
}
}
}
// Arrays.sort(array);
System.out.println(array[9]);
}
}
import java.util.Scanner;
public class ArrayTest {
public static void main(String[] args) {
int[]array = new int[10];
int temp = 0;
System.out.println("请输入成绩:");
for(int i =0;i<array.length;i++){
Scanner sc =new Scanner(System.in);
array[i] = sc.nextInt();
}
for(int x = 0;x<array.length-1;x++){
for(int y = 0;y<array.length-x-1;y++){
if(array[y]>array[y+1]) {
temp = array[y];
array[y] = array[y+1];
array[y+1]=temp;
}
}
}
// Arrays.sort(array);
System.out.println(array[9]);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询