Нарисовать елочку в текстовом режиме CRT — Pascal(Паскаль)

------8-----
----8888----
---888888---
--88888888--
-8888888888-
888888888888
uses crt;
var
   a:array[1..15,1..15] of string;
   i,j,ii:longint;
begin
textcolor(12);
writeln('          +');
   for ii:=1 to 3 do
   for i:=1 to 6 do
   for j:=1 to 11 do
   begin
      textcolor(15);
      a[j,i]:='-';
 
      if (j-i=5)or(i+j=7)or(j=6)or(i=6)then  begin
         a[j,i]:='8';
         textcolor(10);
         end;
      if (j=5)or(j=7) then
         if (i<>1) then begin
            a[j,i]:='8';
            textcolor(10);
            end;
      if (j=4)or(j=8) then
         if (i<>1)and(i<>2) then  begin
          a[j,i]:='8';
          textcolor(10);
          end;
      if (j=3)or(j=9) then
         if (i<>3)and(i<>1)and(i<>2) then   begin
            a[j,i]:='8';
            textcolor(10);
            end;
      write(a[j,i],' ');
      if j=11 then
      writeln;
   end;
   readln;
   end.

Следующий вариант

uses crt;
type mas=array[1..9,1..9] of byte;
procedure Elka(var a:mas;k:byte);
var i,j:byte;
begin
for i:=1 to 7 do
 begin
  gotoXY(30,k+i-1);
  for j:=1 to 13 do
   begin
     if(j>=7-i+1)and(j<=7+i-1) then
     begin
      textcolor(2);
      write(a[i,j]);
     end
    else
     begin
      textcolor(15);
      write(a[i,j]);
     end;
   end;
 end;
end;
var a:mas;
    i,j:byte;
begin
clrscr;
randomize;
for i:=1 to 5 do
for j:=1 to 9 do
a[i,j]:=random(10);
for i:=1 to 3 do
Elka(a,7*(i-1)+1);
readln
end.

Leave a Comment

8 + 2 =