type sharrecord x integer y integer R integer
- Slides: 18
Шарик опишем типом "запись" type shar=record x: integer; y: integer; R: integer; end; var s: shar; R x, y
Прямолинейное движение (1) uses graph, wincrt; const Xmin = 100; Ymin = 100; Xmax = 500; Ymax = 500; var x, y, dx, dy: integer; type shar=record x: integer; y: integer; R: integer; end; var s: shar; procedure My. Graph. Regime; var GD, GM : integer; begin GD : = Detect; Init. Graph(GD, GM, ''); end;
Прямолинейное движение (2) procedure Clear. Shar(st: shar); begin Set. Color(0); Circle(st. x, st. y, st. R); end; procedure Draw. Shar(st: shar); begin Set. Color(9); Circle(st. x, st. y, st. R); end; procedure Move. Shar(var st: shar); begin st. x: =st. x+dx; st. y: =st. y+dy; end;
Прямолинейное движение (3) BEGIN My. Graph. Regime; Set. Color(9); dx: =2; dy: =2; s. x: =300; s. y: =200; s. R: =10; Repeat Clear. Shar(s); Move. Shar(s); Draw. Shar(s); delay(1); until keypressed; Close. Graph; END.
Правим процедуру Move. Shar procedure Move. Shar(var st: shar); begin st. x: =st. x+dx; st. y: =st. y+dy; if (st. x+st. R>Xmax) OR (st. x-st. R<Xmin) then dx: =-dx; if (st. y+st. R>Ymax) OR (st. y-st. R<Ymin) then dy: =-dy; end;
Добавим случайность uses graph, wincrt; const Xmin = 100; Xmax = 500; Ymin = 100; Ymax = 500; var x, y, dx, dy: integer; type shar=record x: integer; y: integer; R: integer; kx: integer; ky: integer; end; var s: shar;
Добавим случайность procedure Move. Shar(var st: shar); begin st. x: =st. x+dx*st. kx; st. y: =st. y+dy*st. ky; if (st. x+st. R>Xmax) OR (st. x-st. R<Xmin) then st. kx: =-st. kx; if (st. y+st. R>Ymax) OR (st. y-st. R<Ymin) then st. ky: =-st. ky; end; BEGIN My. Graph. Regime; Set. Color(9); Rectangle(Xmin, Ymin, Xmax, Ymax); s. x: =300; s. y: =200; s. R: =10; s. kx: =1; s. ky: =1; Repeat dx: =random(5)+1; dy: =random(5)+1; . . . .
- Keep change change integers
- Hypothesis definition
- Type 2 vs type 1 error
- Lead inductance effect in microwave
- Type 2 hit
- Difference between bunch type and spreading type groundnut
- Myotonic dystrophy type 1 vs type 2
- Mixed conditionals structure
- Is hyper v type 1 or type 2
- Null hypothesis
- How can one type of rock change into another type of rock?
- Reference type and value type
- Plunger type transfer moulding
- Type a vs type b
- Null and deflection type instruments
- Name type compatibility and structure type compatibility
- What is the primary function of wave summation
- Type checker in compiler design
- Type type revolution