この課題が私に求めていることを理解するのに非常に苦労しています。私は完全な初心者で、Java/プログラミング全般を数週間学習していますが、これは私にとって非常に困難です。そのため、タイトルがあまり具体的でなくて申し訳ありません。
誰かが私に説明してくれると本当にありがたいです.1つの例のサンプルコードを少し付けてください.何をすべきかを考えます。
ありがとうございました。
加算の仕様:
このプログラムは、コマンド ラインから入力を取得します。
The first input is K, an integer, followed by an arbitrary number a_1, ..., a_N of floating-point numbers.
If K=0, then N is output.
If K > 0, then the a_i are grouped in groups of size K, inside the groups the numbers are multiplied, and all the products are added, yielding the output.
If K < 0, then the summation sums up the reciprocal values of the products.
In the special case K=1 the output thus is a_1 + ... + a_N.
In the case K=-1 the output is 1/a_1 + ... + 1/a_N.
There are two error cases:
If no command-line argument is given, then error-code 1 is to be returned.
If K < 0, and one of a_i = 0, then error-code 2 is to be returned.
In both cases there must be no output.
The return-code of a program is set via System.exit(code);
プログラムの戻りコードは、echo $? を介してコマンド ラインで取得されることに注意してください。他の出力があってはなりません。また、追加のスペースや改行は許可されていません。
エラーがない場合の例を次に示します: http://pastebin.com/F2uz262v