-
Notifications
You must be signed in to change notification settings - Fork 0
/
tachghepmang.pas
91 lines (91 loc) · 1.67 KB
/
tachghepmang.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
program hi;
uses crt;
var m,n,l1,l2,l3:integer;
f:text;
a:array[1..100] of integer;
am:array[1..100] of integer;
duong:array[1..100] of integer;
ko:array[1..100] of integer;
ghep:array[1..100] of integer;
const fi='input.txt';
fo='output.txt';
procedure nhap;
var i:integer;
begin
assign(f,fi);
reset(f);
read(f,n);
for i:=1 to n do
read(f,a[i]);
close(f);
end;
procedure xuat;
var i:integer;
begin
assign(f,fo);
rewrite(f);
for i:=1 to n do
write(f,a[i]:3);
close(f);
end;
procedure mangam;
var i:integer;
begin
l1:=0;
for i:=1 to n do
if a[i]<0 then
begin
l1:=l1+1;
am[l1]:=a[i];
end;
end;
procedure mangduong;
var i:integer;
begin
l2:=0;
for i:=1 to n do
if a[i]>0 then
begin
l2:=l2+1;
duong[l2]:=a[i];
end;
end;
procedure mangko;
var i:integer;
begin
l3:=0;
for i:=1 to n do
if a[i]=0 then
begin
l3:=l3+1;
ko[l3]:=a[i];
end;
end;
procedure mangghep;
var i:integer;
begin
for i:=1 to l1 do
ghep[i]:=am[i];
for i:=1 to l3 do
ghep[l1+i]:=ko[i];
for i:=1 to l2 do
ghep[l1+l3+i]:=duong[i];
end;
procedure xuatghep;
var i:integer;
begin
assign(f,fo);
rewrite(f);
for i:=1 to n do
write(f,ghep[i]:3);
close(f);
end;
begin
nhap;
xuat;
mangam;
mangduong;
mangko;
mangghep;
xuatghep;
end.