- 635 名前:デフォルトの名無しさん [2009/12/21(月) 19:21:19 ]
- 【 課題 】コマンドラインから数値を受け取り、その数値の因数を全て表示するプログラムを完成させなさい。
【 形態 】1. Javaアプリケーション(main()で開始) 【 期限 】あと少しなので今日中にお願いします。 【 Ver 】1.4.2_03 【 補足 】【 】の中身がわからないのでよろしくお願いします。 import java.lang.*; public class kadai { public static void main(final String[] argStringArray) throws Exception { int vInt = 0; int vMax = 0; int vFactor = 0; vInt = Integer.parseInt(argStringArray[0]); vMax = 【 】(int); for(vFactor = 1; vFactor < vMax; vFactor++) { if((vInt % vFactor) == 0) { System.out.println(vInt + " = " + vFactor + " * " + (vInt / vFactor)); }}}} 実行結果 java kadai 8 8 = 1 * 8 8 = 2 * 4 java kadai 120 120 = 1 * 120 120 = 2 * 60 120 = 3 * 40 120 = 4 * 30 120 = 5 * 24 120 = 6 * 20 120 = 8 * 15 120 = 10 * 12
|

|