java编程,从键盘输入10整数存入数组中,输出这10个整数,并求最小值.
1个回答
2016-06-29
展开全部
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = 10;
int[] b = new int[a];
int i=0;
int c = 0;
while(i<a){
b[i]=sc.nextInt();
if(i!=0){
c=(c>b[i])?b[i]:c;
}else{
c=b[i];
}
i++;
}
for(int s:b){
System.out.print(s+" ");
}
System.out.println();
System.out.println("最小数:"+c);
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = 10;
int[] b = new int[a];
int i=0;
int c = 0;
while(i<a){
b[i]=sc.nextInt();
if(i!=0){
c=(c>b[i])?b[i]:c;
}else{
c=b[i];
}
i++;
}
for(int s:b){
System.out.print(s+" ");
}
System.out.println();
System.out.println("最小数:"+c);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询