viết chương trình pascal : tạo hình tam giac *
**
***
****
Chương trình vô cùng đơn giản
program tamgiac;
uses crt;
var i,j,n:integer;
begin
clrscr;
write(‘Nhap n: ‘); readln(n);
for i:=1 to n do
begin
for j:=1 to i do write(‘*’);
writeln;
end;
readln;
end.
Program ve_tam_giac;
uses crt;
var center,i,j,max,h:integer;
max_hang ,k:integer;
begin
clrscr();
Write(‘ Nhap vao chieu cao cua tam giac : ‘);readln(h);
max:=h+h-1;
center:=(max div 2) + 1;
for i=1 to h do
begin
max_hang:=i+i-1;
k:=(max-max_hang) div 2;
for j=1 to max do
begin
if(j>k and j<(k+max_hang+1)) then write(‘*’)
else write(‘ ‘);
end.
writeln(”);
end.
readln();
end.
VOTE MÌNH 5 SAO NHA