PASCAL Viết chương trình tìm và in ra tất cả hoán vị của 12345 ( ví dụ : 12345 12354 12453…) 29/07/2021 Bởi Autumn PASCAL Viết chương trình tìm và in ra tất cả hoán vị của 12345 ( ví dụ : 12345 12354 12453…)
program phuongt; uses crt; var n, n1, n2, n3, n4: integer; begin clrscr; n:=1234; n1:=n div 1000; n2:=(n div 100) mod 10; n3:=(n mod 100) div 10; n4:=n mod 10; write(‘Hoan vi cua ‘, n, ‘ la: ‘); write(n1,n2,n4,n3,’ ‘,n1,n3,n2,n4,’ ‘,n1,n3,n4,n2,’ ‘,n1,n4,n2,n3,’ ‘,n1,n4,n3,n2,’ ‘,n2,n1,n3,n4,’ ‘,n2,n1,n4,n3,’ ‘,n2,n3,n1,n4,’ ‘,n2,n3,n4,n1,’ ‘,n2,n4,n1,n3,’ ‘,n2,n4,n3,n1,’ ‘,n3,n1,n2,n4,’ ‘,n3,n1,n4,n2,’ ‘,n3,n2,n1,n4,’ ‘,n3,n2,n4,n1,’ ‘,n3,n4,n1,n2,’ ‘,n3,n4,n2,n1,’ ‘,n4,n1,n2,n3,’ ‘,n4,n1,n3,n2,’ ‘,n4,n2,n1,n3,’ ‘,n4,n2,n3,n1,’ ‘,n4,n3,n1,n2,’ ‘,n4,n3,n2,n1); readln end. Bình luận
program phuongt;
uses crt;
var n, n1, n2, n3, n4: integer;
begin
clrscr;
n:=1234;
n1:=n div 1000;
n2:=(n div 100) mod 10;
n3:=(n mod 100) div 10;
n4:=n mod 10;
write(‘Hoan vi cua ‘, n, ‘ la: ‘);
write(n1,n2,n4,n3,’ ‘,n1,n3,n2,n4,’ ‘,n1,n3,n4,n2,’ ‘,n1,n4,n2,n3,’ ‘,n1,n4,n3,n2,’ ‘,n2,n1,n3,n4,’ ‘,n2,n1,n4,n3,’ ‘,n2,n3,n1,n4,’ ‘,n2,n3,n4,n1,’ ‘,n2,n4,n1,n3,’ ‘,n2,n4,n3,n1,’ ‘,n3,n1,n2,n4,’ ‘,n3,n1,n4,n2,’ ‘,n3,n2,n1,n4,’ ‘,n3,n2,n4,n1,’ ‘,n3,n4,n1,n2,’ ‘,n3,n4,n2,n1,’ ‘,n4,n1,n2,n3,’ ‘,n4,n1,n3,n2,’ ‘,n4,n2,n1,n3,’ ‘,n4,n2,n3,n1,’ ‘,n4,n3,n1,n2,’ ‘,n4,n3,n2,n1);
readln
end.