題目

判斷大小值

package ch5;
import java.io.*;
public class ch5_10_1
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader in=new InputStreamReader(System.in);
        BufferedReader buf=new BufferedReader(in);
        int a,b,c,min;
        String sa,sb,sc;
        sa=buf.readLine();
        a=Integer.parseInt(sa);
        sb=buf.readLine();
        b=Integer.parseInt(sb);
        sc=buf.readLine();
        c=Integer.parseInt(sc);
        min = a;
        if (b<min)
            min=b;
        if(c<min)
            min=c;
        System.out.println("輸入值a="+a+",b="+b+"c="+c);
        System.out.println("最小值="+min);
    }
}

================

3
1
2
輸入值a=3,b=1c=2
最小值=1

 

創作者介紹
創作者 驢子的生活日記 的頭像
驢子

驢子的生活日記

驢子 發表在 痞客邦 留言(0) 人氣( 46 )