//PascalABC.NET (версия 3.1, сборка 1210 от 29.03.2016) const m = 10;
var t: array[1..m] of integer; i, n, nm, sm: integer;
begin //Заполняем массив сл.числами и подсчитываем //количество элементов и среднее арифметическое //согласно условию задачи for i := 1 to m do begin t[i] := random(-20, 20);write(t[i]:4); if (i > 1) and (i <= m) then if t[i] > t[i - 1] then n := n + 1 else if t[i] < t[i - 1] then begin sm := sm + t[i];nm := nm + 1; end; end; writeln; writeln('число элементов больших предыдущего = ', n); writeln('ср. арифметическое элементов меньших предыдущего = ', sm / nm);
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
// Номер 1
vector <string> days;
for (int i = 0 ; i < 7 ; ++i)
{
string temp;
cin >> temp;
days.push_back(temp);
}
//Номер 2
int max1 = -2000000000;
int max2 = -2000000000;
vector <int> arr { 15, 48, 0, 144 , 52};
for(int i = 0 ; i < arr.size() ; ++i)
max1 = (arr[i] > max1 ? arr[i] : max1);
for(int i = 0 ; i < arr.size() ; ++i)
max2 = (arr[i] > max2 && arr[i] != max1 ? arr[i] : max2);
cout << "Максимум 1: " << max1 << " Максимум 2: " << max2;
//Номер 3
vector <int> numbers { 15, 24, 48, -5 , 0 , -10};
cout << count_if(numbers.begin(), numbers.end(), [] (int a) { return a > 0;});
return 0;
}