0 bình luận về “Nhập số N có phải số chính phương hay ko”
uses crt; var n:longint; begin clrscr; write(‘Nhap n: ‘); readln(n); if sqr(trunc(sqrt(n)))=n then writeln(n,’ la so chinh phuong’) else writeln(n,’ khong phai la so chinh phuong’); readln end.
uses crt;
var n:longint;
begin
clrscr;
write(‘Nhap n: ‘); readln(n);
if sqr(trunc(sqrt(n)))=n then writeln(n,’ la so chinh phuong’)
else writeln(n,’ khong phai la so chinh phuong’);
readln
end.
program chinhphuong;
uses crt;
var n:integer;
begin
clrscr;
repeat
write(‘Nhap n=’); readln(n);
until n>0;
if sqrt(n)=trunc(sqrt(n)) then writeln(n,’ la so chinh phuong’);
else writeln(n,’ khong la so chinh phuong’);
readln;
end.