Untitled
unknown
plain_text
a year ago
3.2 kB
8
Indexable
program DigitalClock; var number: Integer; width, height: Integer; procedure DrawDigit(number, width, height: Integer); var a, b: Integer; begin //которая рисует выбранную цифру case number of 1: begin //цифра 1 for a := 1 to height do begin for b := 1 to width do begin //где должна быть * if (b = (width div 2) + 1) or (a = height) or ((a = 1) and (b > 1) and (b < width)) then Write('*') else Write(' '); end; Writeln; //переход на новую строку после завершения end; end; 2: begin //цифра 2 for a := 1 to height do begin for b := 1 to width do begin //где должна быть * if ((a = 1) or (a = height) or ((a <= height div 2) and (b = width)) or ((a > height div 2) and (b = 1)) or ((a = height div 2 + 1) and (b > 1) and (b < width))) then Write('*') else Write(' '); end; Writeln; end; end; 3: begin // цифра 3 for a := 1 to height do begin for b := 1 to width do begin //где должна быть * if ((a = 1) or (a = height) or (b = width)) or ((a = height div 2 + 1) and (b > 1) and (b < width)) then Write('*') else Write(' '); end; Writeln; end; end; 4: begin //цифра 4 for a := 1 to height do begin for b := 1 to width do begin //где должна быть * if ((a = height div 2 + 1) or (b = width) or (a = height) or ((a <= height div 2) and (b = 1))) then Write('*') else Write(' '); end; Writeln; end; end; 8: begin // цифра 8 for a := 1 to height do begin for b := 1 to width do begin //где должна быть * if ((a = 1) or (a = height) or (b = 1) or (b = width) or (a = height div 2 + 1)) then Write('*') else Write(' '); end; Writeln; end; end; else //если введена неизвестная цифра WriteLn('Неподдерживаемая цифра.'); end; end; begin //основн программа Write('Введите цифру от 1 до 9: '); ReadLn(number); if (number >= 1) and (number <= 9) then begin //ну тут понятно Write('Введите ширину цифры: '); ReadLn(width); Write('Введите высоту цифры: '); ReadLn(height); //вызов процедуры DrawDigit(number, width, height); end else //в случае неизвестного ввода цифры WriteLn('Некорректный ввод. Введите число от 1 до 9.'); end.
Editor is loading...
Leave a Comment