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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
| Program SE;
uses crt;
const m=23; n=8; a=4; b=6; c=4; d=9;
type matrice=array[1..n,1..m]of integer;
tb1=array[1..n,1..a]of integer;
tb2=array[1..n,1..b]of integer;
tb3=array[1..n,1..c]of integer;
tb=array[1..d]of integer;
var i, j, h, w, k, f, g, cpt, fin: integer;
mat:matrice; t1:tb1; t2:tb2; t3:tb3; t:tb;
x:char;
Procedure Job1;
begin
for j:=1 to a do
for i:=1 to n do
t1[i,j]:=1;
end;
Procedure Job2;
begin
for j:=1 to b do
for i:=1 to n do
t2[i,j]:=1;
end;
Procedure Job3;
begin
for j:=1 to c do
for i:=1 to n do
t3[i,j]:=1;
end;
Procedure Indices;
begin
writeln;
t[1]:=4; t[4]:=8; t[7]:=19;
t[2]:=5; t[5]:=15; t[8]:=22;
t[3]:=7; t[6]:=18; t[9]:=23;
end;
Procedure Affectation;
begin
Indices; writeln;
j:=4; k:=1;
while j<=m do
begin
if j=t[k] then
begin
for i:=1 to n do
mat[i,j]:=1; k:=k+1;
end
else j:=j+1;
end;
end;
Procedure Initialiser;
begin
clrscr; textcolor(15);
for i:=1 to n do
for j:=1 to 3 do
mat[i,j]:=1;
Affectation; job1; job2; job3;
k:=0; f:=1;
for j:=1 to m do
begin
for i:=1 to n do
write(mat[i,j]);
write(' ');
if k=0 then
begin
writeln('Jobs:'); k:=k+1;
end
else
if k=1 then
begin
writeln; k:=k+1;
end
else
if k<=5 then
begin
textcolor(3);
for i:=1 to n do
write(t1[i,k]); k:=k+1;
writeln; textcolor(15);
end
else
if (k=6) or (k=7) then
begin
writeln; k:=k+1;
end
else
if k<=13 then
begin
textcolor(6);
for i:=1 to n do
write(t2[i,k]);
write(' '); textcolor(15);
if f<=4 then
begin
textcolor(9);
for i:=1 to n do
write(t3[i,f]);
textcolor(15);
f:=f+1; k:=k+1; writeln;
end
else
begin
textcolor(15);
k:=k+1; writeln;
end;
end
else writeln;
end;
textcolor(15); writeln;
write('Press Enter'); read(x);
clrscr;
end;
Procedure CherchVide;
begin
clrscr;
cpt:=0; j:=4; i:=1;
while (j<=m) and (cpt<w) do
begin
if mat[i,j]=1 then
begin f:=j; j:=j+1; i:=1; cpt:=0; end
else
begin g:=j; j:=j+1; cpt:=cpt+1; end;
end;
h:=0;
end;
Procedure InsertJob;
begin
CherchVide;
for j:=f+1 to g do
begin
h:=h+1;
for i:=1 to n do
begin
if k=1 then mat[i,j]:=t1[i,h]
else
if k=2 then mat[i,j]:=t2[i,h]
else
mat[i,j]:=t3[i,h];
end;
end;
writeln; writeln;
for j:=1 to f do
begin
textcolor(15);
for i:=1 to n do
write(mat[i,j]); writeln;
end;
textcolor(2);
for j:=f+1 to g do
begin
for i:=1 to n do
write(mat[i,j]); writeln;
end;
textcolor(15);
for j:=g+1 to m do
begin
for i:=1 to n do
write(mat[i,j]); writeln;
end;
if (j=m) and (cpt<w) then
begin
textcolor(4);
writeln(' Ce Job doit avoir recours au dcalage');
write(' Si mmoire pleine; statut Job: en attente');
end;
writeln; textcolor(15);
write('Press Enter'); read(x); clrscr;
end;
Procedure Insertion;
begin
clrscr;
writeln; write(' '); textcolor(15);
writeln('JOB en entr: 1,2,3');
textcolor(3);
writeln; write('Choisir:'); textcolor(15);
readln(k);
if k=1 then
begin job1; w:=4; end
else
if k=2 then
begin job2; w:=6; end
else
begin job3;w:=4; end;
InsertJob;
end;
Procedure Decalage;
var cpt:integer;
begin
clrscr; writeln; textcolor(15);
writeln('JOB qui a besoin d''Insertion avec Dcalage: 1,2,3:'); writeln;
writeln; textcolor(3); write('Choisir:');
read(k); textcolor(15);
if k=1 then
begin job1; w:=4; end
else
if k=2 then
begin job2; w:=6; end
else
begin job3; w:=4; end;
j:=4; g:=0; cpt:=0;
repeat i:=1;
while i<=n do
begin
if mat[i,j]=1 then
begin
if g<>0 then
begin
for i:=1 to n do
mat[i,g]:=mat[i,j];
for i:=1 to n do
mat[i,j]:=0; g:=g+1; j:=j+1; i:=1;
end
else
begin j:=j+1; i:=1; end;
end
else i:=i+1;
end;
if g=0 then g:=j;
j:=j+1; cpt:=cpt+1;
until (cpt=w); CherchVide;
for j:=f+1 to g do
begin
h:=h+1;
for i:=1 to n do
begin
if k=1 then mat[i,j]:=t1[i,h]
else
if k=2 then mat[i,j]:=t2[i,h]
else
mat[i,j]:=t3[i,h];
end;
end;
writeln;textcolor(15);
for j:=1 to f do
begin
for i:=1 to n do
write(mat[i,j]); writeln;
end;
textcolor(2);
for j:=f+1 to g do
begin
for i:=1 to n do
write(mat[i,j]); writeln;
end;
textcolor(6);
for j:=g+1 to m do
begin
for i:=1 to n do
write(mat[i,j]); writeln;
end;
writeln; textcolor(15);
write('Press Enter');
readln(x); clrscr;
end;
Procedure Main;
begin
clrscr; writeln; writeln;
repeat
write(' ');textcolor(3);
writeln(' Principal Main');
writeln;writeln;writeln;writeln;
write(' ');textcolor(15);
writeln('1:Initialisation');writeln;
write(' ');
writeln('2:Insertion Directe');writeln;
write(' ');
writeln('3:Insertion avec Dcalage');writeln;
write(' ');
writeln('4:Exit');writeln;writeln;
write(' ');textcolor(3);
writeln;writeln;writeln;
writeln;writeln;writeln; writeln;
write(' Entrer Nø:');
readln(Fin);
case Fin of
1:Initialiser;
2:Insertion;
3:Decalage;
4:Exit;
end;
until Fin=4;
end;
Begin
Accueil;
textbackground(0); clrscr;
Main;
End. |