標題:
陣列 (三)
[打印本頁]
作者:
tonyh
時間:
2012-10-27 16:31
標題:
陣列 (三)
本帖最後由 tonyh 於 2012-10-27 16:52 編輯
利用二維陣列, 試做一個包含五位同學, 各三組分數的成績表格.
表格的形式如下:
座號 國文 英文 數學 平均
==================
1
2
3
4
5
public class ch37
{
public static void main(String args[])
{
float score[][]={{68,78,90,0},{55,70,78,0},{78,98,80,0},{35,56,55,0},{63,76,77,0}};
System.out.println("座號\t國文\t英文\t數學\t平均");
System.out.println("=========================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
for(int j=0; j<=3; j++)
{
System.out.print(score[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
作者:
t3742238
時間:
2012-10-27 16:54
public class ch37
{
public static void main(String args[])
{
float score[][]={{68,78,90,0},{55,70,78,0},{78,98,80,0},{35,56,55,0},{63,76,77,0}};
System.out.println("座號\t國語\t英文\t數學\t平均");
System.out.println("===========================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
for(int j=0; j<=3; j++)
{
System.out.print(score[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
作者:
t2364705
時間:
2012-10-27 16:55
public class ch37
{
public static void main(String args[])
{
float score[][]={{70,65,97,0},{88,74,67,0},{99,81,63,72},{54,91,87,0},{84,67,59,0}};
System.out.println("座號\t國文\t英文\t數學\t平均");
System.out.println("====================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
score [i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
for(int j=0; j<=3; j++)
{
System.out.print(score[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
作者:
尤泓鈞
時間:
2012-10-27 16:56
public class ch34
{
public static void main(String args[])
{
float score[][]={{68,78,90,0},{55,70,78,0},{78,98,80,0},{35,56,55,0},{63,76,77,0}};
System.out.println("座號\t國語\t英文\t數學\t平均");
System.out.println("===========================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
for(int j=0; j<=3; j++)
{
System.out.print(score[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
作者:
粘靖瑜
時間:
2012-10-27 17:00
public class ch37
{
public static void main(String args[])
{
float score[][]={{68,78,90,0},{55,70,78,0},{78,98,80,0},{35,56,55,0},{63,76,77,0}};
System.out.println("座號\t國文\t英文\t數學\t平均");
System.out.println("=========================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
for(int j=0; j<=3; j++)
{
System.out.print(score[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
作者:
蔡昀佑
時間:
2012-10-27 17:01
public class ch37
{
public static void main(String args[])
{
float score[][]={{68,78,90,0},{55,70,78,0},{78,98,80,0},{35,56,55,0},{63,76,77,0}};
System.out.println("座號\t國語\t英文\t數學\t平均");
System.out.println("===========================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
for(int j=0; j<=3; j++)
{
System.out.print(score[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
作者:
黃博鴻
時間:
2012-11-3 14:54
public class ch37
{
public static void main(String args[])
{
float score[][]={{78,45,25,0},{89,45,89,0},{98,89,98,0},{99,99,79,0},{56,21,12,0}};
System.out.println("座號\t國文\t英文\t數學\t平均");
System.out.println("=================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
for(int j=0; j<=3; j++)
{
System.out.print(score[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
作者:
劉漢文
時間:
2012-11-3 15:03
public class ch37
{
public static void main(String args[])
{
float score[][]={{23,44,56,0},{85,70,71,0},{78,98,80,0},{35,12,55,0},{69,93,93,0}};
System.out.println("座號\t國文\t英文\t數學\t平均");
System.out.println("=================================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
for(int j=0; j<=3; j++)
{
System.out.print(score[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2