Skip to content

Instantly share code, notes, and snippets.

@vertrigo
Created November 20, 2012 10:09
Show Gist options
  • Select an option

  • Save vertrigo/4117105 to your computer and use it in GitHub Desktop.

Select an option

Save vertrigo/4117105 to your computer and use it in GitHub Desktop.
Program ex5;
uses crt;
const n = 5;
type matr = array[1..n,1..n] of integer;
vect = array[1..n] of integer;
var a:matr; b:vect; i,j:integer;
Procedure inputm(var m:matr; s:integer);
var i,j:integer;
begin
writeln('Введите матрицу ',n,'x',n,':');
for i:=1 to s do
for j:=1 to s do read(m[i,j]);
end;
Procedure outputm(m:matr; s:integer);
var i,j:integer;
begin
writeln('Исходная матрица ',n,'x',n,':');
for i:=1 to s do begin
for j:=1 to s do write(m[i,j]:3);
writeln;
end;
end;
Function inside(m:integer):boolean;
begin
inside:=((10 < m) or (m < 0));
end;
Begin
clrscr;
inputm(a,n);
outputm(a,n);
for i:=1 to n do b[i]:=0;
for i:=1 to n do
for j:=1 to n do
if (inside(a[i,j])) then b[i]:=b[i]+1;
writeln('Полученный вектор b:');
for i:=1 to n do write(b[i]:3);
readkey;
End.
Program rgr6;
uses crt;
const mc = 100;
pr = 20;
type assort = (bananas, candy, cookies, cake, pie,
buns, wafer, jelly, cmilk, chocolate,
scake, cream, honey, fruit, berries,
icream, eggs, sugar, nuts, starch);
const names: array[0..19] of string = ('бананы', 'конфеты', 'печенье', 'пирожное', 'торт',
'булочки', 'вафельки', 'желе', 'сгущенка', 'шоколад',
'бисквит', 'крем', 'мед', 'фрукты', 'ягоды',
'сливки', 'яйца', 'сахар', 'орехи', 'крахмал');
type stock = set of assort;
type shopinfo = record
products:stock;
end;
var shop:array[1..mc] of shopinfo; stocks:stock;
goods:assort; inall,recent:stock;
uniq:boolean; i,count,cn:integer;
Procedure FillSet;
var i,j,r:integer;
begin
for i:=1 to mc do
shop[i].products:=[];
for i:=1 to mc do
for j:=1 to pr do begin
r:=random(20);
include(shop[i].products,assort(r));
end;
end;
Begin
clrscr;
randomize;
FillSet;
inall:=[];
recent:=[];
uniq:=false;
for goods:=bananas to starch do begin
count:=0;
for i:=1 to mc do begin
if goods in shop[i].products then count:=count+1;
end;
if (count = 100) then include(inall, goods);
if (count > 60) and (count < 100) then include(recent, goods);
if (count = 1) then uniq:=true;
end;
writeln;
writeln('Виды сластей, которые имеются во всех магазинах города:');
if inall = [] then writeln('таких видов нет!') else begin
for goods:=bananas to starch do begin
if goods in inall then begin
write(names[ord(goods)]);
write(' ');
end;
end;
end;
cn:=0;
writeln;
writeln('5 видов сластей, которые имеются в большинстве магазинов города:');
for goods:=bananas to starch do begin
if goods in recent then begin
write(names[ord(goods)]);
write(' ');
cn:=cn+1;
end;
if (cn = 5) then break;
end;
writeln;
writeln;
if uniq then writeln('В городе есть магазин, торгующий уникальной продукцией.')
else writeln ('В городе нет магазинов, торгующих уникальной продукцией.');
writeln;
readkey;
End.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment