#include <iostream>
#include <cmath>
using namespace std;
signed main() {
int n;
cin >> n;
double a[n];
for(int i = 0; i < n; i++)
cin >> a[i];
double mx = -10000000000000;
for(int i = n/2; i < n; i++)
mx = max(mx,a[i]);
for(int i = 0; i < n-1; i++)
for(int j = 0; j < n - i - 1; j++)
if(a[j] > a[j+1])
{
double temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
cout << "maximal element of the second half: " << mx <<"\n";
cout << "array after sorting: " << "\n";
for(auto i: a)
cout << i << " ";
PascalABC.NET 3.5.1 + .NET Framework 4.7.1
#1
begin
var n := ReadInteger();
var a := Range(1, n);
//Sum
a.Sum.Println;
//произведение
a.Aggregate(BigInteger.One, (p, q) -> p * q).Println;
//Кол-во кратных 2 и 3
a.Where(p -> (p mod 2 = 0) and (p mod 3 = 0)).Count.Println;
//Среднее ряда
a.Average.Round.Println
end.
#2
var A := ReadArrInteger(10);
A.Println;
//максимум
A.Max.Println;
//Сумма кратных 2 и 3
A.Where(p -> (p mod 2 = 0) and (p mod 3 = 0)).Sum.Println
#include <iostream>
#include <cmath>
using namespace std;
signed main() {
int n;
cin >> n;
double a[n];
for(int i = 0; i < n; i++)
cin >> a[i];
double mx = -10000000000000;
for(int i = n/2; i < n; i++)
mx = max(mx,a[i]);
for(int i = 0; i < n-1; i++)
for(int j = 0; j < n - i - 1; j++)
if(a[j] > a[j+1])
{
double temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
cout << "maximal element of the second half: " << mx <<"\n";
cout << "array after sorting: " << "\n";
for(auto i: a)
cout << i << " ";
}
PascalABC.NET 3.5.1 + .NET Framework 4.7.1
#1
begin
var n := ReadInteger();
var a := Range(1, n);
//Sum
a.Sum.Println;
//произведение
a.Aggregate(BigInteger.One, (p, q) -> p * q).Println;
//Кол-во кратных 2 и 3
a.Where(p -> (p mod 2 = 0) and (p mod 3 = 0)).Count.Println;
//Среднее ряда
a.Average.Round.Println
end.
#2
begin
var A := ReadArrInteger(10);
A.Println;
//максимум
A.Max.Println;
//Сумма кратных 2 и 3
A.Where(p -> (p mod 2 = 0) and (p mod 3 = 0)).Sum.Println
end.