返回列表 發帖
  1. public class TQC107{

  2.         public static void main(String args[]){
  3.                 float tot = 0 ;
  4.                 for(int i=1;i<args.length;i++){
  5.                         tot += Float.parseFloat(args[i]);
  6.                 }
  7.                 tot /= (args.length-1) ;
  8.                
  9.                 if(args[0].equals("0")){
  10.                         System.out.printf("平均值:%f",tot);
  11.                 }else if(args[0].equals("1")){
  12.                         System.out.printf("平均值:%.1f",tot);
  13.                 }else{
  14.                         System.out.printf("平均值:%.2f",tot);
  15.                 }
  16.                
  17.                
  18.         }


  19. }
複製代碼

TOP

返回列表