Topic: 一个小小程序(关于数组)

  Print this page

1.一个小小程序(关于数组) Copy to clipboard
Posted by: wslss007
Posted on: 2005-10-28 16:49

public class hi{
  
    static float score[][]={
      (1,90,80,0)
      (2,69,78,0)
      (3,89,67,0)
      (4,77,89,0)
      (5,67,98,0)
      };
      public static void main(String args[]){
      String str1=new String();
      int i,j;
      for(i=0;i<5;i++){
        score[i][3]=(score[i][1]+score[i][2])/2;
        }
     for(i=0;i<5;i++){
       str1="";
       for(j=0;j<4;j++){
         str1=str1+""+score[i][j];}
         System.out.println(str1);
       }
      
      
    }
  
}

此程序编译结果如下,d:\JCREAT~1\MyProjects\hi.java:4: 需要 ')'
      (1,90,80,0)
^
1 错误

不明白,也许很白痴的问题,但我实在看不出来,帮帮忙。

2.Re:一个小小程序(关于数组) [Re: wslss007] Copy to clipboard
Posted by: bwpc
Posted on: 2005-10-28 17:03

static float score[][] = { { 1, 90, 80, 0 }, { 2, 69, 78, 0 },
      { 3, 89, 67, 0 }, { 4, 77, 89, 0 }, { 5, 67, 98, 0 } };


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923