を合計し、それはあなたの番号を尋ね、その数の10倍を表示し、それらを合計しますが、それはこのようにする必要があり:Javaの表示数の10倍と彼らにこのプログラムに
数= 6;
06、12、18、24、30、36、42、48、54、60
60、54、48、42、36、30、24、18、12、06
合計= 324
数字を表示する部分は問題ありません。問題は合計しなければならない場合です。私はリストを使用して各行の番号を保存し、最初の行/リストを使用して合計しましたが、動作させることができませんでした。
ArrayList<Integer> i1 = new ArrayList();
ArrayList<Integer> i2 = new ArrayList();
System.out.println("Introduce un número:\n"); // Asks you a number
int n1=scan.nextInt();
int add_i = 0;
int rest_i = n1 * 11;
i1.add(add_i);
i2.add(rest_i);
while (add_i <= n1 * 9) // while add_i is less or equal to n1 * 9
{
add_i += n1; // suma n1 a i
System.out.print(i1 + " "); // Prints the result
}
System.out.println(" ");
while (rest_i >= 10) // while rest_i is greater or equal than 10
{
rest_i -= n1; // Resta n1 a i
System.out.print(i2 + " "); // Prints result
}
また、私のプログラムでは、マルチは表示されません。
OP、あなたの最新の編集が_destroyed_質問に残っています。編集内容は明らかですが、現時点では質問をしていたコードは完全に消えています。 –
あなたの質問に解決コードを貼り付けないでください...私はこの質問が他の人を助けるかもしれないと疑っていますが、これはこのサイトの目的を全滅させます! – ParkerHalo