program ProgForBeer_MoreBeerAndGirls;
uses
crt;
var
m : array[1..100] of integer; // first array
m2: array[1..100] of integer; // second array
m3: array[1..200] of integer; // last main array (1+2)
i,j,n,buf,BigN,Sett,k : integer; // index,addindex,MaxNumElems,buffer
// MaxNumElemsM3, MatchVariable
begin
ClrScr; // Clear the display view buffer
write('Enter maximal number of elements for the first and second array: ');
readln(n);
Write('You has two ',n,' elements array. Press ENTER...');
ReadLn;
for i:=1 to n do // enter n array "m[i]"
begin
write('Enter element as index m[',i,' of ',n,'] : ');
readln(m[i])
end;
for i:=1 to n-1 do // sort array m[i] elements
for j:=i+1 to n do
if m[i]<m[j] then
begin
buf:=m[i];
m[i]:=m[j];
m[j]:=buf;
end;
WriteLn('Array M[i] was countdown sorted...');
for i:=1 to n do
write(m[i],' ');
Readln;
Write('Now, you must enter ',n,' elements of the second array. Press ENTER...');
ReadLn;
for i:=1 to n do // enter n array "m2[i]"
begin
write('Enter element as index m2[',i,' of ',n,'] : ');
readln(m2[i])
end;
for i:=1 to n-1 do // sort array m2[i] elements
for j:=i+1 to n do
if m2[i]<m2[j] then
begin
buf:=m2[i];
m2[i]:=m2[j];
m2[j]:=buf;
end;
WriteLn('Array M2[i] was countdown sorted...');
for i:=1 to n do
write(m2[i],' ');
Readln;
BigN:=N*2; // get number of main array elements
For i:=1 to N do // generate first part of array cycle
m3[i]:=m[i];
For i:=1 to N do // generate second part of array cycle
m3[i+n]:=m2[i];
Write('The program was generate main array. Press ENTER...');
ReadLn;
for i:=1 to BigN do
write(m3[i],' ');
WriteLn;
Write('Now start process of checking the matches. Press ENTER...');
Readln;
For i:=1 to BigN do // Checking the matches
begin
Buf:=m3[i];
Sett:=0;
For j:=1 to BigN do // main cycle
if m3[j]=Buf then // detect match index
begin
Inc(Sett);
if Sett>1 then // detect match element
for k:=1 to BigN do
if m3[k]=Buf then
begin
if m3[k]<>-32000 then
WriteLn('Element number ',k,' as BAD! (',m3[k],')');
m3[k]:=-32000;//delete match element (set max type resourse)
end;
end;
end;
for i:=1 to BigN-1 do // sort array m3[i] elements
for j:=i+1 to BigN do
if m3[i]<m3[j] then
begin
buf:=m3[i];
m3[i]:=m3[j];
m3[j]:=buf;
end;
WriteLn('Program was delete from array M3[i] matched elements,');
WriteLn('and procedured the countdown operation...');
for i:=1 to BigN do
if m3[i]<>-32000 then write(m3[i],' ');
WriteLn;
WriteLn;
TextColor(Yellow);
Sound(700);
WriteLn('08.12.2010 Manif');
Delay(5000);
NoSound;
Readln;
TextColor(White);
End.