program detales;
const
N = 20; // размер партии
var
batch: array[1..N] of Real;
model: Integer;
deviation: Integer;
i,j,dev: Integer;
begin
Writeln;
Writeln('Obshee kolichestvo detaley v partii "N" (sht): ',N);
Writeln;
Write('Vvedite etalonniy razmer detali [1 - 100](cm) : ');
Readln(model);
Write('Vvedite dopustimoe otklonenie "K" [1 - 9](mm) : ');
Readln(deviation);
Writeln;
Randomize;
dev := (deviation+5)*2; // отклонение в обе стороны + 10 мм на брак :-)
Writeln('============ Partiya postupivshih tovarov =================');
for i := 1 to N do
begin
batch[i] := model + (Random(dev) - deviation) /10;
if (i mod 5 = 0) then // Выводим (по 5 элементов в строку, через знак табуляции #9)
Writeln('T[',i,'] = ',batch[i]:6:1,';')
else
Write('T[',i,'] = ',batch[i]:6:1,';',#9);
end;
Writeln;
Writeln('============ Kachestvennie tovary =================');
j := 1;
for i := 1 to N do
begin
if (abs(model - batch[i]) <= deviation/10) then
begin
if (j mod 5 = 0) then
Writeln('T[',i,'] = ',batch[i]:6:1,';')
else
Write('T[',i,'] = ',batch[i]:6:1,';',#9);
Inc(j);
end;
end;
Writeln;
Writeln('============ Brakovannie tovary =================');
j := 1;
for i := 1 to N do
begin
if (abs(model - batch[i]) > deviation/10) then
begin
if (j mod 5 = 0) then // Выводим (по 5 элементов в строку, через знак табуляции #9)
Writeln('T[',i,'] = ',batch[i]:6:1,';')
else
Write('T[',i,'] = ',batch[i]:6:1,';',#9);
Inc(j);
end;
end;
Writeln;
Writeln('Zakonchili. Nazmite <ENTER> dlya vihoda');
Writeln;
Readln;
end.