算法训练 最大值与最小值的计算

算法训练 最大值与最小值的计算  
时间限制:1.0s   内存限制:512.0MB
    
  输入11个整数,计算它们的最大值和最小值。
样例输入
0 1 2 3 4 5 6 7 8 9 10
样例输出
10 0
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int temp;
        int min=1000000000;
        int max=-1000000;
        for(int i=0;i<11;i++){
            temp=sc.nextInt();
            if(temp>max) max=temp;
            if(temp<min) min=temp;
        }
        System.out.println(max+" "+min);

    }

}
原文地址:https://www.cnblogs.com/watchfree/p/5356472.html