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

Notebook VI

推薦 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]) ;//印出7個陣列11~23
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”);
}
}

台長: 娃娃♡°

您可能對以下文章有興趣

人氣(68) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 心情日記(隨筆、日記、心情手札) | 個人分類: 程式設計⊙ˇ⊙ |
此分類下一篇:notebook VII
此分類上一篇:notebookV

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