已知三角形的底和高,求出三角形的面积。 每行输入底和高     //这句话要怎么实现它每行输出三角形的面积。精确到三位小数。 Sample Input
1 2 
3 4
5 6Sample Output
1.000
6.000
15.000

解决方案 »

  1.   

    什么意思?
    你是问System.in.read()的用法?
      

  2.   

    public static void readScore()
    {
        int countOfStudent=5,i=0;
        float score[]=new float[countOfStudent];
        try {
        BufferedReader in = new BufferedReader(new FileReader("company.record"));    while ((str=in.readLine()) != null&&i++<countOfStudent) {
            score[i] = Float.parseFloat(in.readLine().trim());
        }
        in.close();
        } catch (IOException e) {
        //IOException happened!
            System.out.println("Exception was thrown when reading from file!");
        }
        //求平均值,排序我就不写了~
        .....
    }
      

  3.   

    try {
        BufferedReader in = new BufferedReader(new FileReader("Input.txt"));    if((str1=in.readLine()) != null&&(str2=in.readLine()) != null) {
            a=Float.parseFloat(str1.trim());
            h=Float.parseFloat(str2.trim());
        }
        s=a*h/2;
        in.close();
        } catch (IOException e) {
        //IOException happened!
            System.out.println("Exception was thrown when reading from file!");
        }