第1个回答 推荐于2018-06-20
import java.util.Scanner;
public class NumTest {
public static void main(String[] args) {
int[] nums=new int[10];
Scanner jin = new Scanner(System.in);
for (int i = 0; i < nums.length; i++) {
nums[i]=jin.nextInt();
}
int smallerNum=nums[0];
int biggerNum=nums[0];
System.out.print("这十个数是:");
for (int i = 0; i < nums.length; i++) {
System.out.print(" "+nums[i]);
if (smallerNum>nums[i]) {
smallerNum=nums[i];
}
if (biggerNum<nums[i]) {
biggerNum=nums[i];
}
}
System.out.println();
System.out.println("最小值为:"+smallerNum);
System.out.println("最大值为:"+biggerNum);
}
}本回答被网友采纳