Bài 6. Câu lệnh điều kiện

Harunastu

Các bạn giúp mình với!!!

Minh Lệ
18 tháng 6 2021 lúc 21:49

Program HOC24;

const fi='BAI2.INP'

fo='BAI2.OUT'

var f: text;

i,j,n,dem,t1,t2: longint;

function kt1(x,y: longint): boolean;

var s1,s2,s3,s4: string;

d,j: longint;

begin

kt1:=false;

str(x,s1);

str(y,s2);

d:=0; s3:='' s4:=''

for j:=length(s2) downto 1 do s3:=s3+s2[j];

for j:= length(s1) downto 1 do s4:=s4+s1[j];

for j:=1 to length(s1) do

if s4[j]=s3[j] then d:=d+1;

if (d=length(s1)) and (x*x=y) then kt1:=true else kt1:=false;

end;

procedure ip;

begin

assign(f,fi);

reset(f);

read(f,n);

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

dem:=0;

for i:=1 to n do

for j:=1 to n do

if kt1(i,j) then dem:=dem+1;

writeln(f,dem);

for i:=1 to n do

for j:=1 to n do

if kt1(i,j) then

writeln(f,'(',i,'',j,')');

close(f);

end;

begin

ip;

out;

end.

Bình luận (0)

Các câu hỏi tương tự
Harunastu
Xem chi tiết
Xem chi tiết
Đào Cẩm
Xem chi tiết
Thiên Phúc
Xem chi tiết
Harunastu
Xem chi tiết
phạm ngọc hân
Xem chi tiết
Phương Lan
Xem chi tiết
Anh Nguyễn Tú
Xem chi tiết
_silverlining
Xem chi tiết