24h購物| | PChome| 登入
2007-12-18 10:41:40| 人氣28| 回應0 | 上一篇 | 下一篇

優秀娃打ㄉ

推薦 0 收藏 0 轉貼0 訂閱站台

public class InitArray
{
public static void main(String args[])
{
final int ARRAY_LENGTH = 7;
int array[] = new int[7];
for ( int counter = 0; counter < array.length;counter++)
array[ counter ] = 11+2*counter;
System.out.printf("%s%8sn","Index","Value");
for ( int counter = 0; counter < array.length;counter++)
System.out.printf("%5d%8dn",counter,array[ counter]) ;
int total = 0;
for ( int counter = 0; counter < array.length;counter++)
total +=array[counter];
System.out.printf("nTolal= %dn",total);
for ( int counter = 0; counter < array.length;counter++){
System.out.printf("n%d:",counter);
for(int i=0;i< array[counter];i++)
System.out.printf("%c",’*’);
}
System.out.printf("n");
}
}

台長: eva
人氣(28) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文