My Opera is closing 3rd of March
photo of Nguyễn Văn Ngọc

Blog của playgemboy

Lạc quan yêu đời nhưng vẫn dành thời gian để buồn và suy ngẫm.

Bài giải của đề Pascal<---->

Đề:
Viết chương trình sử dụng thủ tục vẽ hình tam giác vuông cân cạnh a ("đặc ruột") lên màn hình và xoay đủ 4 hướng:
vd: a=5


--------------------1
*
**
***
****
*****
--------------------2
*****
****
***
**
*
--------------------3
*****
 ****
  ***
   **
    *
--------------------4
    *
   **
  ***
 ****
*****
--------------------5



Đây là bài giải:



Program VeTamGiacVuongCan;

Procedure Ve1(Canh:Integer);
var X,Y:Integer;
Begin
   If Canh>1 then
    Begin
      For Y:=1 to Canh do
      Begin
        For X:=1 to Y do write('*');
        writeln;
      End;
    End;
End;
Procedure Ve2(Canh:Integer);
var X,Y:Integer;
Begin
   If Canh>1 then
    Begin
      For Y:=Canh downto 1 do
      Begin
        For X:=1 to Y do write('*');
        writeln;
      End;
    End;
End;

Procedure Ve3(Canh:Integer);
var X,Y:Integer;
Begin
   If Canh>1 then
    Begin
      For Y:=1 to canh do
      Begin
      write('':y-1) ;
        For X:=1 to canh-y+1 do write('*');
        writeln;
      End;
    End;
End;
Procedure Ve4(Canh:Integer);
var X,Y:Integer;
Begin
   If Canh>1 then
    Begin
      For Y:=canh downto 1 do
      Begin
      write('':y-1) ;
        For X:=1 to canh-y+1 do write('*');
        writeln;
      End;
    End;
End;
Begin
writeln('-----------Ve1-----------------');
ve1(5);
writeln('-----------Ve2-----------------');
ve2(5);
writeln('-----------Ve3-----------------');
ve3(5);
writeln('-----------Ve4-----------------');
Ve4(5);
readln;
end.


Thêm một mẹo vặt để phát hiện USB có virus hay ko ?Cách lắp SIM mobile vào điện thoại cố định không dây của Viettel

Comments

Nguyễn Hữu Anh TuấnNguyenHuuAnhTuanComputer Tuesday, March 25, 2008 6:50:47 PM

Cũng được đó, tui còn cách khác.Đường nào rồi cũng vể La mã

Unregistered user Friday, January 8, 2010 4:02:39 AM

Ngô Kim Phú writes: Thử cách này coi, tui tự làm đấy. Nó cũng chỉ hơi khác chút thôi. (Copy cái này vào file notepad hoặc wordpad, lưu lại rồi đổi đuôi .txt thành .pas. Nếu không thấy đuôi thì vào Tool -> Folder Options... -> View -> Bỏ chọn ô Hide extensions for known file types) -------------------------------------------------------------- Program Ve4LoaiTamGiac; Uses crt; Var KT:byte; Procedure TG1(a:byte); Var dem1,dem2:byte; Begin For dem1 :=1 to a do Begin For dem2 := a-dem1 downto 1 do write(' '); For dem2 := 1 to dem1 do write('*'); GotoXY(WhereX-a,WhereY+1); End; End; (**********************************) Procedure TG2(a:byte); Var dem1,dem2:byte; Begin For dem1 :=1 to a do Begin For dem2 := 1 to dem1 do write('*'); GotoXY(WhereX-dem1,WhereY+1); End; End; (**********************************) Procedure TG3(a:byte); Var dem1,dem2:byte; Begin For dem1 :=a downto 1 do Begin For dem2 := 1 to a-dem1 do write(' '); For dem2 := 1 to dem1 do write('*'); GotoXY(WhereX-a,WhereY+1); End; End; (**********************************) Procedure TG4(a:byte); Var dem1,dem2:byte; Begin For dem1 :=a downto 1 do Begin For dem2 := 1 to dem1 do write('*'); GotoXY(WhereX-dem1,WhereY+1); End; End; (**********************************) Begin Clrscr; Write('Nhap kich thuoc tam giac vuong can can ve (tu 1 den 22) : '); Readln(KT); If KT in [1..22] then Begin GotoXY(12,3); TG1(KT); GotoXY(KT+14,3); TG2(KT); GotoXY(12,KT+5); TG3(KT); GotoXY(KT+14,KT+5); TG4(KT); End Else writeln('Da bao la tu 1 den 20 thoi ma!'); Readln; End.

Unregistered user Friday, January 8, 2010 2:21:53 PM

Anonymous writes: Hi hi, code hay qua.

Write a comment

New comments have been disabled for this post.