依次将10个数输入,要求将其中最大的数打印出来
来源:百度知道 编辑:UC知道 时间:2024/05/25 06:10:41
只要求输出最大数,也就是说,要考虑到程序的计算速度,能精简就精简
不要用太复杂的方法,我是个C新手,刚看到的课后练习题。谢谢拉
不要用太复杂的方法,我是个C新手,刚看到的课后练习题。谢谢拉
public class Sort {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int max = 0;
int a[] = new int[10];
System.out.println("请输入10个数,用空格隔开:");//输入数据
for (int i = 0; i < 10; i++) {
a[i] = in.nextInt();
}
for (int j = 0; j < a.length; j++) {
if (a[j] > a[max]) {
max = j;
}
}
System.out.printl