module pind.samples.ja.arithmetic.arithmetic_solution_2; import std.stdio; void main() { int first; write("Please enter the first number: "); readf(" %s", &first); int second; write("Please enter the second number: "); readf(" %s", &second); int quotient = first / second; int remainder = first % second; // 残りが0であるかどうかを判断する前に、 // writelnを事前に呼び出すことはできない。 // 行は後でwritelnで終了させる必要がある。 write(first, " = ", second, " * ", quotient); // 残りは0以外の場合にのみ表示する必要がある。 if (remainder != 0) { write(" + ", remainder); } // これで、行を終了する準備ができた。 writeln(); }