1)#include <iostream>
using namespace std;
int main()
{
int x;//вводит пользователь
int y;//фунцыя
cout << "Please enter x > ";
cin >> x;
if (x <= -2 & x <= 2)//если -2<=x<=2
y = x * x;
else
y = 4;
cout << "From x : " << x << "; Y = " << y << endl;
system("pause");
return 0;
}
2)
#include <iostream>
using namespace std;
int main()
{
int x;//вводит пользователь
int y;//функцыя
cout << "Enter x > ";
cin >> x;
if (x < 2)
y = (1 + cos(2 * x)) / 2;//формула cos^2 X;
else
y = 1 + (1 - cos(2 * x)) / 2;//формула sin^2 X;
cout << "Your function from X : " << x << "; Y = " << y << endl;
system("pause");
return 0;
}
<em>Возможно запорол с формулами, перепроверь наверняка.</em>
<span>Язык: Pascal
</span>
Var
a,b:integer;
Begin
read(a,b);
write(a+b);
End.
<span>Язык C++
</span>
<span>#include <iostream>
using namespace std;
int main() {
int a,b;
cin >> a;
cin >> b;
cout << a+b;
return 0;
}
Язык JavaScript
var a = Number(prompt());
var b = Number(prompt());
alert(a+b); // или console.log(a+b);
ИЛИ
alert( Number(prompt()) + Number(prompt()) );
Язык Python
a = int(input())
b = int(input())
print(a+b)
ИЛИ
print( int(input()) + int(input()) )
</span>
Ввод для любой программы выше:
2
5
Вывод:
7
<u>PascalABC.NET 3.3.5, сборка 1662 от 29.04.2018</u>
<u>Внимание! Если программа не работает, обновите версию!</u>
begin
var n:=ReadInteger('n=');
if n<9 then n:=9; // от дурака
var d:=ArrRandom(n,-50,50);
Write('Исходный массив: '); d.Println;
var i:=1;
repeat
d[i]*=2; i+=2
until i>n-1;
Write(' После удвоения: '); d.Println;
d:=d[:1]+d[2:8]+d[9:];
Write(' После удаления: '); d.Println
end.
<u>Пример</u>
n= 15
Исходный массив: -13 -33 48 -47 -9 19 -21 45 10 -4 -30 40 -31 0 -2
После удвоения: -13 -66 48 -94 -9 38 -21 90 10 -8 -30 80 -31 0 -2
После удаления: -13 48 -94 -9 38 -21 90 -8 -30 80 -31 0 -2
Program qwerty;vara,b,c,d:integer;beginwriteln('Введи ширину');readln(a);writeln('Введи длину');readln(b);c:=a*b;d:=a+a+b+b;writeln('площадь: ');writeln(c);writeln('периметр: ');writeln(d);end.