0 bình luận về “viết chương trình tìm tổng 2 số đối xứng”
program abcxyz; uses crt; var a,aa,b,bb,s,ss: longint; begin clrscr; write(‘nhap mot so bat ki a:’); readln(a); write(‘nhap mot so bat ki b:’); readln(b); aa:=a; s:=0; while a<>0 do begin s:=s*10+a mod 10; a:=a div 10; end; writeln(‘so doi xung cua ‘,aa,’ la:’,s:4); bb:=b; ss:=0; while b<>0 do begin ss:=ss*10+b mod 10; b:=b div 10; end; writeln(‘so doi xung cua ‘,bb,’ la:’,ss:4); writeln(‘tong doi xung cua hai so a,b la: ‘,s+ss); readln end.
{Var x,xx,y,yy,s,ss: longint; Begin Write(‘Nhap mot so bat ki x:’); readln(x); write(‘nhap mot so bat ki y:’); readln(y); xx:=x; s:=0; while x<>0 do begin s:=s*10+x mod 10; x:=x div 10; end; writeln(‘so doi xung cua ‘,xx,’ la:’,s:4); yy:=y; ss:=0; while y<>0 do Begin zz:=zz*10+y mod 10; y:=y div 10; end; writeln(‘so doi xung cua ‘,yy,’ la:’,zz:4); writeln(‘tong doi xung cua hai so x,y la: ‘,z+zz); readln end.}
program abcxyz;
uses crt;
var a,aa,b,bb,s,ss: longint;
begin
clrscr;
write(‘nhap mot so bat ki a:’); readln(a);
write(‘nhap mot so bat ki b:’); readln(b);
aa:=a;
s:=0;
while a<>0 do
begin
s:=s*10+a mod 10;
a:=a div 10;
end;
writeln(‘so doi xung cua ‘,aa,’ la:’,s:4);
bb:=b;
ss:=0;
while b<>0 do
begin
ss:=ss*10+b mod 10;
b:=b div 10;
end;
writeln(‘so doi xung cua ‘,bb,’ la:’,ss:4);
writeln(‘tong doi xung cua hai so a,b la: ‘,s+ss);
readln
end.
{Var x,xx,y,yy,s,ss: longint;
Begin
Write(‘Nhap mot so bat ki x:’); readln(x);
write(‘nhap mot so bat ki y:’); readln(y);
xx:=x;
s:=0;
while x<>0 do
begin
s:=s*10+x mod 10;
x:=x div 10;
end;
writeln(‘so doi xung cua ‘,xx,’ la:’,s:4);
yy:=y;
ss:=0;
while y<>0 do
Begin
zz:=zz*10+y mod 10;
y:=y div 10;
end;
writeln(‘so doi xung cua ‘,yy,’ la:’,zz:4);
writeln(‘tong doi xung cua hai so x,y la: ‘,z+zz);
readln
end.}
Program và uses Crt k cần thiết nhé !