標題:
陣列 (六)
[打印本頁]
作者:
tonyh
時間:
2014-7-12 14:06
標題:
陣列 (六)
本帖最後由 tonyh 於 2014-7-12 14:41 編輯
針對上一個練習, 新增 "姓名" 與 "平均" 欄位.
[attach]923[/attach]
public class ch38
{
public static void main(String args[])
{
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int n[][]={{90,85,85,0},
{70,75,80,0},
{80,95,80,0},
{70,95,75,0},
{80,85,95,0}};
System.out.println("座號\t姓名\t國文\t英文\t數學\t平均");
System.out.println("=============================================");
for(int i=0; i<5; i++)
{
n[i][3]=(n[i][0]+n[i][1]+n[i][2])/3;
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0; j<4; j++)
{
System.out.print(n[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
作者:
張瀚仁
時間:
2014-7-12 14:38
public class ch37
{
public static void main(String args[])
{
String name[]={"as","ad","sf","ag","jl"};
int n[][]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
System.out.println("座號\t姓名\t國文\t英文\t數學\t平均");
System.out.println("===================================================");
for(int i=0; i<5; i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0; j<3; j++)
{
System.out.print(n[i][j]+"\t");
}
System.out.println((n[i][0]+n[i][1]+n[i][2])/3);
}
}
}
複製代碼
作者:
林以諾
時間:
2014-7-12 14:48
public class ch38
{
public static void main(String args[])
{
String name[]={"以","諾","是","帥","哥"};
int n[][]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
System.out.println("座號\t姓名\t國文\t英文\t數學\t平均");
System.out.println("=========================================");
for(int i=0; i<5; i++)
{
System.out.print((i+1)+"\t");
System.out.print(name[i]+"\t");
for(int j=0; j<3; j++)
{
System.out.print(n[i][j]+"\t");
}
System.out.println((n[i][0]+n[i][1]+n[i][2])/3);
}
}
}
複製代碼
作者:
黃崇維
時間:
2014-7-15 17:49
public class ch37
{
public static void main(String args[])
{
String name[]={"as","ad","sf","ag","jl"};
int n[][]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
System.out.println("座號\t姓名\t國文\t英文\t數學\t平均");
System.out.println("===================================================");
for(int i=0; i<5; i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0; j<3; j++)
{
System.out.print(n[i][j]+"\t");
}
System.out.println((n[i][0]+n[i][1]+n[i][2])/3);
}
}
}
複製代碼
作者:
劉泳鱔
時間:
2014-7-15 17:50
public class ch38
{
public static void main(String args[])
{
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int n[][]={{90,85,85,0},
{70,75,80,0},
{80,95,80,0},
{70,95,75,0},
{80,85,95,0}};
System.out.println("座號\t姓名\t國文\t英文\t數學\t平均");
System.out.println("=============================================");
for(int i=0; i<5; i++)
{
n[i][3]=(n[i][0]+n[i][1]+n[i][2])/3;
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0; j<4; j++)
{
System.out.print(n[i][j]+"\t");
}
System.out.println();
}
}
}
複製代碼
作者:
許逸群
時間:
2014-8-26 17:07
public class ch37
{
public static void main(String args[])
{
String name[]={"as","ad","sf","ag","jl"};
int n[][]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
System.out.println("座號\t姓名\t國文\t英文\t數學\t平均");
System.out.println("===================================================");
for(int i=0; i<5; i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0; j<3; j++)
{
System.out.print(n[i][j]+"\t");
}
System.out.println((n[i][0]+n[i][1]+n[i][2])/3);
}
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2