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.
2024-03-10 20:32:51 +03:00

26 lines
836 B
ObjectPascal
Raw Permalink 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.

uses System;
var
str_arr: array of string;
int_arr: array of integer;
s: string := '12 765 765 76';
begin
// Разбиение строки на массив подстрок с заданным разелителем
str_arr := s.Split(' ');
// Соединение массива подстрок с новым разделителем
s := string.Join('+', str_arr);
Write(s, '=');
// Формирование целочисленного массива по массиву подстрок
SetLength(int_arr, str_arr.Length);
for var i:=0 to int_arr.Length-1 do
integer.TryParse(str_arr[i], int_arr[i]);
// Вычисление суммы элементов целочисленного массива
var sum := 0;
foreach v: integer in int_arr do
sum += v;
Writeln(sum);
end.