dlang-book/05-данные-и-функции-функцио.../src/chapter-5-2-3/app.d

17 lines
452 B
D
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Вы­чис­ля­ет ча­ст­ное и ос­та­ток от де­ле­ния для ар­гу­мен­тов a и b.
// Воз­вра­ща­ет ча­ст­ное по зна­че­нию, а ос­та­ток в па­ра­мет­ре rem.
int divrem(int a, int b, out int rem)
{
assert(b != 0);
rem = a % b;
return a / b;
}
unittest
{
int r;
int d = divrem(5, 2, r);
assert(d == 2 && r == 1);
}