hoang
Giới thiệu về bản thân
bài 1;
const
fi='phantich.inp';
fo='phantich.out';
var f,g:text;i,n,d:longint;
function nt(n:longint):boolean;
var i:longint;
begin
if (n<2) then exit (false);
for i:=2 to trunc(sqrt(n)) do
if (n mod i=0) then exit (false);
exit (true);
end;
begin
assign(f,fi);reset(f);
assign(g,fo);rewrite(g);
readln(f,n);
d:=0;
for i:=1 to n div 2 do
if nt(i) and nt(n-i) then inc(d);
writeln(g,'co ',d,' cach phan tich');
close(f);close(g);
end.
bài 2:
const
fi='primenumber.inp';
fo='primenumber.out';
var f,g:text;n:longint;
function nt(n:longint):boolean;
var i:longint;
begin
if (n<2) then exit (false);
for i:=2 to trunc(sqrt(n)) do
if (n mod i=0) then exit (false);
exit (true);
end;
function check(n:longint):boolean;
var s,m:longint;
begin
s:=0;m:=n;
while (n>0) do
begin
s:=s*10+(n mod 10);
n:=n div 10;
end;
if (s=m) and (nt(s)=true) then exit (true);
exit (false);
end;
begin
assign(f,fi);reset(f);
assign(g,fo);rewrite(g);
readln(f,n);
if check(n) then writeln(g,'la so nguyen to doi xung') else
writeln(g,'khong la so nguyen to doi xung');
repeat
inc(n);
until (check(n)=true);
writeln(g,'so do la : ',n);
close(f);close(g);
end.
const
fi='sochinhphuong.inp';
fo='sochinhphuong.out';
var f,g:text;n:longint;
function scp(n:longint):boolean;
begin
if (sqr(trunc(sqrt(n)))=n) then exit (true);
exit (false);
end;
begin
assign(f,fi);reset(f);
assign(g,fo);rewrite(g);
readln(f,n);
if scp(n) then writeln(g,'yes') else
writeln(g,'no');
close(f);close(g);
end.