dlang-book/04-массивы-ассоциативные-ма.../src/chapter-4-1/app.d

27 lines
440 B
D
Raw Normal View History

2023-02-25 14:15:12 +00:00
import std.random;
import std.stdio;
void main()
{
// От 1 до 127 эле­мен­тов
auto array = new double[uniform(1, 128)];
foreach (i; 0 .. array.length)
{
array[i] = uniform(0.0, 1.0);
}
writeln(array);
foreach (ref element; array)
{
element = uniform(0.0, 1.0);
}
writeln(array);
auto copy = array.dup;
assert(array !is copy);
assert(array == copy);
}