Вопрос задан 15.02.2019 в 13:32. Предмет Информатика. Спрашивает Лыдина Александра.

ОТДАМ ВСЕ БАЛЛЫ, надо нарисовать в PasalABC часы , в которых 3 стрелки, а в поле ввода, нужно

ввести время, которое должно показываться на нарисованных часах, угол считать в градусах, а не в радианах, часы должны ходить
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Рублёв Александр.
Uses graphAbc;

const
 w = 600;
 r = 300;

dl = 40;
sl = 250;
ml = 200;
hl = 150;

var
 h,m,s: integer;
 i:integer;
 x,y: integer;
 g: real;
 
begin
 setwindowsize(w,w);
 read(h,m,s);
 h := h mod 12;
 setpenwidth(2);
 circle(w div 2, w div 2, r);
 for i := 0 to 59 do
   begin
   g := (i*360/60 - 90) * pi/180;
   if i mod 12 = 0 then
     begin
     x := w div 2 + round((r - dl) * cos(g));
     y := w div 2 + round((r - dl) * sin(g));
     end
   else
     begin
     x := w div 2 + round((r - dl div 3) * cos(g));
     y := w div 2 + round((r - dl div 3) * sin(g));
     end;
   line(x,y,w div 2 + round(r*cos(g)),w div 2 + round(r*sin(g)))
   end;
 setbrushcolor(clwhite);  while true do
   begin
   setpencolor(clwhite);
   circle(w div 2, w div 2, sl);
   setpencolor(clblack);
      setpenwidth(1);
   g := (6*s - 90) * pi/180;
   x := w div 2 + round(sl * cos(g));
   y := w div 2 + round(sl * sin(g));
   line(w div 2, w div 2, x, y);
      setpenwidth(2);
   g := ((60*m + s)/10 - 90) * pi/180;
   x := w div 2 + round(ml * cos(g));
   y := w div 2 + round(ml * sin(g));
   line(w div 2, w div 2, x, y);

   setpenwidth(3);
   g := (360*(60*60*h + 60*m + s)/12/60/60 - 90) * pi/180;
   x := w div 2 + round(hl * cos(g));
   y := w div 2 + round(hl * sin(g));
   line(w div 2, w div 2, x, y);
      s := s + 1;
   if s = 60 then
     begin
     m := m + 1;
     s := 0;
     end;
   if m = 60 then
     begin
     h := (h + 1) mod 12;
     m := 0
     end;

   sleep(1000)
   end;
end.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Drawing Clock with Three Hands in PascalABC

To draw a clock with three hands in PascalABC, you can use the following code as a starting point:

```pascal program Clock;

uses Graph;

var gd, gm, midx, midy, radius, hr, min, sec: integer; hrx, mnx, scx, hry, mny, scy: real;

begin gd := Detect; InitGraph(gd, gm, '');

midx := GetMaxX div 2; midy := GetMaxY div 2; radius := 200;

while not KeyPressed do begin hr := 10; { Replace with the input hour } min := 30; { Replace with the input minute } sec := 45; { Replace with the input second }

hrx := midx + 50 * sin((hr mod 12 + min / 60) * 30 * (pi / 180)); hry := midy - 50 * cos((hr mod 12 + min / 60) * 30 * (pi / 180)); mnx := midx + 80 * sin(min * 6 * (pi / 180)); mny := midy - 80 * cos(min * 6 * (pi / 180)); scx := midx + 100 * sin(sec * 6 * (pi / 180)); scy := midy - 100 * cos(sec * 6 * (pi / 180));

Line(midx, midy, round(hrx), round(hry)); Line(midx, midy, round(mnx), round(mny)); Line(midx, midy, round(scx), round(scy));

Delay(1000); ClearDevice; end;

CloseGraph; end. ```

Replace the placeholders for `hr`, `min`, and `sec` with the input time values. This code uses the `Graph` unit to draw the clock with three hands in PascalABC. The hour, minute, and second hands are calculated based on the input time, and the clock is updated every second.

Remember to handle user input for the time and integrate it into the code for a complete solution.

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос