展开全部
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);
}
}
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);
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询