Thuat toan tim UCLNGui em Thu

1 3 0
Thuat toan tim UCLNGui em Thu

Đang tải... (xem toàn văn)

Thông tin tài liệu

[r]

(1)

Thuật toán tìm UCLN Bài toán: Tìm ƯCLN hai số tự nhiên a b

Gi¶i Program UCLN;

Uses CRT;

Var a, b, r, temp: byte; Begin

Clrscr;

Write('Moi ban nhap hai so a, b: ');readln(a,b); if (a = 0) and (b = 0) then

Begin

Write(' Moi ban nhap lai'); Exit;

End;

if (a = 0) then Begin

Write(' UCLN lµ ',b); Exit;

End;

if (b = 0) then Begin

Write(' UCLN lµ ',b); Exit;

End;

if (a<b) then Begin

temp:=a; a:= b; b:=temp; end;

r: = a mod b; While r <> Begin

a:= b; b:=r;

r: = a mod b; end;

Write(' UCLN = ',b); Readln;

Ngày đăng: 27/04/2021, 03:54

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan