Truyen2U.Net quay lại rồi đây! Các bạn truy cập Truyen2U.Com. Mong các bạn tiếp tục ủng hộ truy cập tên miền mới này nhé! Mãi yêu... ♥

thi hk tin

uses

crt;

const

fi = 'data.inp';

fo = 'data.out';

maxn = 1000;

var

f1 , f2 : text;

n , i , j , tmp , tong : longint;

a : array [1..maxn] of longint;

nto : array [1..maxn] of boolean;

procedure mofile;

begin

assign(f1 , fi);

reset(f1);

assign(f2 , fo);

rewrite(f2);

end;

procedure nhap;

begin

n := 0;

while not eoln(f1) do

begin

n := n + 1;

read(f1 , a[n]);

end;

end;

procedure dong1;

begin

writeln(f2 , n);

end;

procedure sapxep;

begin

for i := 1 to n do

for j := i + 1 to n do

if (a[i] > a[j]) then begin

tmp := a[i];

a[i] := a[j];

a[j] := tmp;

end;

end;

procedure dong2;

begin

sapxep;

for i := 1 to n do

write(f2 , a[i] , ' ');

writeln(f2);

end;

function nguyento(a : longint) : boolean;

begin

if (a <= 1) then

exit(false);

for j := 2 to trunc(sqrt(a)) do

if (a mod j = 0) then

exit(false);

exit(true);

end;

procedure dong3;

begin

for i := 1 to n do

nto[i] := nguyento(a[i]);

for i := 1 to n do

if (nto[i]) then

write(f2 , a[i] , ' ');

for i := n downto 1 do

if (nto[i] = false) then

write(f2 , a[i] , ' ');

writeln(f2);

end;

procedure dong4;

begin

for i := 1 to n do

if (a[i] mod 3 = 0) or (a[i] mod 5 = 0) or (a[i] mod 7 = 0) then

write(f2 , a[i] , ' ');

writeln(f2);

end;

function sieunguyento(a : longint) : boolean;

begin

while (a > 0) do begin

if (nguyento(a) = false) then

exit(false);

a := a div 10;

end;

exit(true);

end;

procedure dong5;

begin

for i := 1 to n do

if (sieunguyento(a[i])) then

write(f2 , a[i] , ' ');

writeln(f2);

end;

function hoanthien(a : longint) : boolean;

begin

tong := 0;

for j := 1 to a div 2 do

if (a mod j = 0) then

tong := tong + j;

exit(tong = a);

end;

procedure dong6;

begin

for i := 1 to n do

if (hoanthien(a[i])) then

write(f2 , a[i] , ' ');

end;

procedure dongfile;

begin

close(f1);

close(f2);

end;

begin

mofile;

nhap;

dong1;

dong2;

dong3;

dong4;

dong5;

dong6;

dongfile;

end.

Bạn đang đọc truyện trên: Truyen2U.Com

Tags: