#include <iostream>
using namespace std;
int main()
{
int x;
cout << "Введите значение X: ";
cin >> x;
if (x >= -4 && x <= 1)
{
cout << "1";
}
else
{
cout << "0";
}
}
Объяснение:
#include <iostream> // Библиотека ввода - вывода
using namespace std; // Пространство имён
int main()
{
int x; // Создание целочисленной переменной x
cout << "Введите значение X: "; // Вывод сообщения в консоль
cin >> x; // Вводим значение с клавиатуры
if (x >= -4 && x <= 1) // Если значение переменной x ≥ -4 И ≤ 1
{
cout << "1"; // Выводим 1
}
else // Иначе
{
cout << "0"; // Выводим 0
}
}
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
int N; // исходный размер.
std::cin >> N;
std::vector<int> arr(N);
int number(0);
for(int i = 0; i < N; i++)//инициализируем вектор значениями с клавиатуры.
{
static int temp;
std::cin >> temp;
if(temp % 2 == 0)
{
if(!number)
number = temp;
temp += number;
}
arr.push_back(temp);
}
for(const auto& i : arr)
std::cout << i << std::endl;
}
Оттабулируешь сам(-а).
Компилировал в стандарте С++14, компилятор g++
uses crt;
var a,ed,des,sot,tis,s,p,max:longint;
begin
clrscr;
writeln('введите четырех значное число');
readln(a);
ed:=a mod 10;
des:=a div 10 mod 10;
sot:=a div 100 mod 10;
tis:=a div 1000;
s:=0; p:=1;
p:=ed*des*sot*tis;
s:=ed+des+sot+tis;
writeln('Произведение чисел = ',p);
writeln('Сумма чисел = ',s);
if (ed>des) and (ed>sot) and (ed>tis) then max:=ed;
if (des>ed) and (des>sot) and (des>tis) then max:=des;
if (sot>ed) and (sot>des) and (sot>tis) then max:=sot;
if (tis>ed) and (tis>des) and (tis>sot) then max:=tis;
writeln('Максимальное число = ',max);
readln;
end.