Язык C++. 1. #include <iostream> using namespace std; int main() { int i; cout <<"Введите число: " << endl; cin >> i; cout << "Вы ввели число: " << i << endl; }
2. #include <iostream> using namespace std; int main (){ int i; cout << "Vvod" << endl; cin >> i; i %= 10; if(i %2 != 0) cout << "Нечетная" << endl; else cout << "Четная" << endl; }
3. #include<iostream> using namespace std; int main (){ for(int k = 0; k<4; k++){ cout << "random number = " << rand() << endl; } }
4. #include <iostream> using namespace std; int main(){ int i,a,b,c; cin >> i; c = i%10; b =(i/10)%10; a = i/100; if(i*i==a*a*a+b*b*b+c*c*c) cout<<"Является."<<endl; else cout<<"Не является."<<endl; }
5. #include <iostream> #include <cmath> const double pi = 3.1415926536; using namespace std; int main(){ float x = 0; cout << "Введите x: " << endl; cin >> x; cout << "y = " << sin((pi*(3.2+(sqrt(1+x))))/180)/abs(5*x) << endl; }
Добавляем "pi" и делим на 180, чтобы "sin" был в градусах.
Uses Crt; const n=10; var a,b:array[1..n] of integer; i,k,t:integer; begin ClrScr; Randomize; for i:=1 to n do begin a[i]:=Random(50); Write(a[i],' ') end; Writeln; for i:=1 to n do begin b[i]:=Random(50); Write(b[i],' ') end; Writeln; Write('k t='); Read(k,t); for i:=1 to n do begin if a[i]>t then a[i]:=a[i]+4; Write(a[i],' ') end; Writeln; for i:=1 to n do begin if b[i]>10*k then b[i]:=b[i]+k; Write(b[i],' ') end; Readkey end.
у куба в основании лежит квадрат:
P = 4*а = 20
a = 5см
V = а*а*а = 5^3 = 125 см^3