Удачи в изучении языка.
#include <iostream>
#include <clocale>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
int n;
int *a;
cout << "Введите размер массива : ";
cin >> n;
a = new int[n];
int k = 0;
for (int i = 0; i < n; i++)
cin >> a[i];
cout << "Четные элементы : ";
for (int i = 0; i < n; i++)
if (a[i] % 2 == 0)
{
cout << " " << a[i];
k++;
}
cout << endl;
cout << "Количество четных чисел: " << k << endl;
for (int i = 1; i < n; ++i) //Пузырьковая сортировка
{
for (int t = 0; t < n - i; t++)
{
if (a[t] < a[t + 1])
{
int temp = a[t];
a[t] = a[t + 1];
a[t + 1] = temp;
}
}
}
cout << "Отсортрованный массив по убыванию: ";
for (int i = 0; i < n; i++)
cout << a[i] << " ";
cout << endl;
system("pause");
return 0;
}
Var
n,i,flag:integer;
function fact(n:integer):integer;
begin
if n=0 then fact:=1 else fact:=fact(n-1)*n;
end;
begin
readln(n);
n:=fact(n);
flag:=0;
for i:=1 to (n div 3)+2 do
if i*(i+1)*(i+2)=n then
begin
flag:=1;
writeln(n,'=',i,'*',i+1,'*',i+2);
end;
if flag=0 then writeln('Невозможно');
end.
Пример ввода:
6
Пример вывода:
720=8*9*10