Перенос страниц
This commit is contained in:
parent
4d57446057
commit
4c954c9186
129 changed files with 14 additions and 15 deletions
24
book/03-инструкции/src/chapter-3-9/app.d
Normal file
24
book/03-инструкции/src/chapter-3-9/app.d
Normal file
|
@ -0,0 +1,24 @@
|
|||
import std.math, std.stdio;
|
||||
|
||||
struct Point
|
||||
{
|
||||
double x, y;
|
||||
double norm()
|
||||
{
|
||||
return sqrt(x * x + y * y);
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
Point p;
|
||||
int z;
|
||||
|
||||
with (p)
|
||||
{
|
||||
x = 3; // Присваивает значение полю p.x
|
||||
p.y = 4; // Хорошо, что все еще можно явно использовать p
|
||||
writeln(norm()); // Выводит значение поля p.norm, то есть 5
|
||||
z = 1; // Поле z осталось видимым
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue