procedure Ввод(a: array of string);
begin
for var i := 0 to a.High do
a[i] := ReadlnString;
end;
procedure Вывод(a: array of string);
begin
a.PrintLines
end;
function Сумма(a: array of string): integer;
begin
Result := a.Select(t -> t.ToInteger).Sum;
end;
begin
var n := ReadlnInteger('Укажите общее количество строк:');
var a := new string[n];
Ввод(a);
Вывод(a);
Println('Сумма равна', Сумма(a))
end.
using System;
namespace App {
internal class Program {
private static void Main() {
Console.Write("Введите количество элементов массива:");
var a = new int[Convert.ToInt32(Console.ReadLine())];
Console.WriteLine("\nВведите элементы массива:");
for (var i = 0; i < a.Length; i++) {
Console.Write($"Элемент номер {i} = ");
a[i] = Convert.ToInt32(Console.ReadLine());
}
// используется foreach вместо for потому что это стандартный инструмент для перебора которого нет в паскале
Console.WriteLine("\nисходный массив:");
foreach (var element in a) {
Console.Write($"{element} ");
}
var max = a[0];
foreach (var element in a) {
if (element > max) max = element;
}
Console.WriteLine($"\nMaximum={max}");
// убрана ненужная переменная
foreach (var element in a) {
Console.WriteLine($"Отклонение={max - element}");
}
Console.ReadKey();
}
}
}
Рыбаки сделали во льду 3,7,2,7,8,9,11(прорубь)
и стали ловить рыбу.
Самый колючий зверь в лесу – это 12,13.(еж)
А теперь расшифруйте пословицу:
1,2,3,4,5,1,6 (копейка)
7,8,9,10,11 (рубль) 9,4,7,4,13,12,14 (бережет)
копейка рубль бережет