program p1;
uses Crt;
var
i, n, m, min: integer;
begin
ClrScr;
Write('Длина последовательности: ');
Readln(n);
Read(min);
for i := 2 to n do
Read(m);
if m < min then
min := m;
end;
Writeln(min);
ReadKey;
end.
program p2;
i, n, m, max, k: integer;
Read(max);
k := 1;
if m > max then
max := m;
end
else if m = max then
k := k + 1;
Writeln(k);
C# 8.0:
using System;
...
public static void InsertToArr<T>(ref T[] Arr, in T Value, in int Index){
T[] NewArr = new T[Arr.Length + 1];
for (int i = 0; i < Index; i++) NewArr[i] = Arr[i];
NewArr[Index] = Value;
for (int i = Index + 1; i < NewArr.Length; i++) NewArr[i] = Arr[i-1];
Arr = NewArr;
}
Console.ReadLine(); //skips N
var Arr =Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
var temp = Console.ReadLine().Split(' ');
InsertToArr(ref Arr, int.Parse(temp[0]), int.Parse(temp[1])-1);
foreach (int i in Arr) Console.Write(i + " ");
program p1;
uses Crt;
var
i, n, m, min: integer;
begin
ClrScr;
Write('Длина последовательности: ');
Readln(n);
Read(min);
for i := 2 to n do
begin
Read(m);
if m < min then
min := m;
end;
Writeln(min);
ReadKey;
end.
program p2;
uses Crt;
var
i, n, m, max, k: integer;
begin
ClrScr;
Write('Длина последовательности: ');
Readln(n);
Read(max);
k := 1;
for i := 2 to n do
begin
Read(m);
if m > max then
begin
max := m;
k := 1;
end
else if m = max then
k := k + 1;
end;
Writeln(k);
ReadKey;
end.
C# 8.0:
using System;
...
public static void InsertToArr<T>(ref T[] Arr, in T Value, in int Index){
T[] NewArr = new T[Arr.Length + 1];
for (int i = 0; i < Index; i++) NewArr[i] = Arr[i];
NewArr[Index] = Value;
for (int i = Index + 1; i < NewArr.Length; i++) NewArr[i] = Arr[i-1];
Arr = NewArr;
}
...
Console.ReadLine(); //skips N
var Arr =Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
var temp = Console.ReadLine().Split(' ');
InsertToArr(ref Arr, int.Parse(temp[0]), int.Parse(temp[1])-1);
foreach (int i in Arr) Console.Write(i + " ");