Можно несколько покороче:
Код:
Var
i,j: Integer;
Found: Boolean;
begin
Found := False;
for i := 1 to Length(Edit1.Text)
do for j := 1 to Length(Edit2.Text)
do if Edit1.Text[i] = Edit2.Text[j]
then Found := True;
if Found then ShowMessage('Есть')
else ShowMessage('Нет')
end;
или так:
Код:
Var
i: Integer;
Found: Boolean;
begin
Found := False;
for i := 1 to Length(Edit1.Text)
do if Pos(Edit1.Text[i],Edit2.Text) <> 0
then Found := True;
if Found then ShowMessage('Есть')
else ShowMessage('Нет')
end;
вторая задача так, только вывод в файл сделайте сами:
Код:
Var
PriceList: Array[1..15] of TTransport;
i, Count: Integer;
Average: Real;
begin
for i := 1 to 15
do begin
case Random(2)
of 0: PriceList[i].ModelType := 'Легковой';
1: PriceList[i].ModelType := 'Грузовой';
end;
PriceList[i].Price := (1+Random(9))*10000;
end;
Average := 0;
Count := 0;
for i := 1 to 15
do begin
if PriceList[i].ModelType = 'Легковой'
then begin
Average := Average + PriceList[i].Price;
Inc(Count);
end;
end;
Average := Average / Count;
ShowMessage('Средняя сумма ='+FloatToStr(Average)+' Совпало='+IntToStr(Count));
end;