This repository has been archived on 2024-12-25. You can view files and clone it, but cannot push or open issues or pull requests.
2023-06-20 21:52:24 +03:00

22 lines
513 B
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Обобщенные функции
// Выведение типа T по типам параметров
function IndexOf<T>(a: array of T; val: T): integer;
begin
Result := -1;
for var i:=0 to a.Length-1 do
if a[i]=val then
begin
Result := i;
exit;
end;
end;
var a := Arr('Ваня', 'Коля', 'Саша', 'Сережа');
begin
var s := 'Сережа';
writelnFormat('Индекс элемент со значением ''{0}'' равен {1}',s,IndexOf(a,s));
end.