Ладно, я сегодня с утра добрый.
Вот задача про товарный склад.
1. Скачайте файл Store.txt и поместите его в корневой каталог диска С:.
store.txt
2. Оттранслируйте и запустите программу:
Код:
Type
Things=Record
Name:String[10];
Amount:Word;
Price:Word;
End;
Var
N,i,Item,Imin,Imax:Byte;
Sum:LongInt;
Min,Max:Word;
f:Text;
Goods:Array[1..100] of Things;
Begin
Assign(f,'C:\Store.txt');
Reset(f);
N:=0;
Repeat
Inc(N);
with Goods[N] do
begin
read(f,Name);
read(f,Amount);
readln(f,Price);
end;
Until EoF(f);
Close(f);
Repeat
Writeln;
Writeln('Show:');
Writeln(' 1 - full list of goods');
Writeln(' 2 - lowest anf highest price goods');
Writeln(' 3 - full price of all goods');
Writeln(' 4 - Exit');
Readln(Item);
Case Item of
1: for i:=1 to N do writeln(Goods[i].Name);
2: begin
Min:=Goods[1].Price;
Imin:=1;
Max:=Goods[1].Price;
Imax:=1;
for i:=2 to N do
begin
if Goods[i].Price<Min then
begin
Min:=Goods[i].Price;
Imin:=i;
end;
if Goods[i].Price>Max then
begin
Max:=Goods[i].Price;
Imax:=i;
end;
end;
Writeln('Minimal: ',Goods[Imin].Name,' (',Goods[Imin].Price,')');
Writeln('Maximal: ',Goods[Imax].Name,' (',Goods[Imax].Price,')');
end;
3: begin
Sum:=0;
for i:=1 to N do Inc(Sum,Goods[i].Price*Goods[i].Amount);
Writeln('Full price of all goods: ',Sum);
end;
else Item:=4;
end;
Until Item=4;
End.