0
import java.util.Scanner;
public class Zad01 {

public static void main(String[] args) {

  int [] n;  n = new int [9]; //install

  n[0] = 1;
  n[1] = 3;
  n[2] = 5;
  n[3] = 3;
  n[4] = 4;    //Grades
  n[5] = 2;
  n[6] = 2;
  n[7] = 3;
  n[8] = 3;

  int cnt;
  System.out.println("Grades:");
  for(cnt = 0;n.length > cnt;cnt++)
  {

    System.out.println(n[cnt]);     

    if()
    {


    }
    else
    {

     System.out.println("Error");

    }


   }              
  }     
}   

我不确定要输入什么(如果)。基本上我需要做的是从(n)系列中取出所有数字,将它们相加,然后除以 9。我不知道该怎么做一行...任何帮助将不胜感激!

4

1 回答 1

1
double sum = 0;

for(int c : n)
     sum += c;

double average = sum / n.length;
于 2012-11-02T21:38:02.690 回答