Viết chương trình kiểm tra 2 số nguyên tố bằng nhau bằng chương trình con( Thủ tục) với Turbo Pascal. Giúp mình với nhé !
0 bình luận về “Viết chương trình kiểm tra 2 số nguyên tố bằng nhau bằng chương trình con( Thủ tục) với Turbo Pascal. Giúp mình với nhé !”
program oken; uses crt; var a,b: longint; function kt(a,b: longint): boolean; var i,test: longint; begin for i:=1 to b do if (a mod i=0) then if (b mod i=0) then test:= i; if (test=1) then kt:= true else kt:= false; end; begin clrscr; write(‘Nhap so a: ‘); readln(a); write(‘Nhap so b: ‘); readln(b); writeln(‘Ket qua: ‘,kt(a,b)); readln; end.
uses crt; var a,b,t:longint; procedure ntbn; var i:longint; begin for i:=1 to a do if(a mod i=0)and(b mod i=0)then t:=i; end; begin clrscr; write(‘a=’);readln(a); write(‘b=’);readln(b); ntbn; if t=1 then writeln(‘Co’) else writeln(‘Khong’); readln end.
program oken;
uses crt;
var a,b: longint;
function kt(a,b: longint): boolean;
var i,test: longint;
begin
for i:=1 to b do
if (a mod i=0) then
if (b mod i=0) then
test:= i;
if (test=1) then
kt:= true
else
kt:= false;
end;
begin
clrscr;
write(‘Nhap so a: ‘); readln(a);
write(‘Nhap so b: ‘); readln(b);
writeln(‘Ket qua: ‘,kt(a,b));
readln;
end.
uses crt;
var a,b,t:longint;
procedure ntbn;
var i:longint;
begin
for i:=1 to a do if(a mod i=0)and(b mod i=0)then t:=i;
end;
begin
clrscr;
write(‘a=’);readln(a);
write(‘b=’);readln(b);
ntbn;
if t=1 then writeln(‘Co’) else writeln(‘Khong’);
readln
end.