1.
var x,y:integer;
begin
write('x = ');
readln(x);
if x>0
then y:=1
else if x=0 then y:=0 else y:=-1;
writeln('y = ',y);
end.
Пример:
x = -5
y = -1
2.
var a,b,c,x1,x2,d:real;
begin
writeln('Введите a, b, c:');
readln(a,b,c);
d:=b*b-4*a*c;
if d>0
then begin
x1:=(-b+sqrt(d))/(2*a);
x2:=(-b-sqrt(d))/(2*a);
writeln('x1 = ',x1,' x2 = ',x2);
end
else if d=0 then begin
x1:=-b/(2*a);
writeln('x = ',x1);
end
else writeln('Корней нет');
end.
Пример:
Введите a, b, c:
2 5 -3
x1 = 0.5 x2 = -3
3.
var a,b,c:real;
begin
writeln('Введите a, b, c:');
readln(a,b,c);
if (a<=b)and(b<=c)
then begin
b:=a; c:=a;
end
else begin
a:=-a; b:=-b; c:=-c;
end;
writeln('a = ',a,' b = ',b,' c = ',c);
end.
Пример 1:
Введите a, b, c:
2 5 9
a = 2 b = 2 c = 2
Пример 2:
Введите a, b, c:
2 9 5
a = -2 b = -9 c = -5
#include<iostream>
#include<stdlib.h>
#include<ctime>
using namespace std;
int main()
{
srand(time(0));
setlocale(LC_CTYPE,"rus");
const int First=5;
const int Second=5;
int ArrFirst[First],ArrSecond[Second],a=0,b=0;
for(int i=0;i<5;i++)
{
ArrFirst[i]=rand()%20+1;
ArrSecond[i]=rand()%20+1;
a=ArrFirst[i]-ArrSecond[i];
b=ArrFirst[i]+ArrSecond[i];
cout<<a<<"\t"<<b<<"\n";
}
return 0;}
Var a: integer;
begin
write('Введите трехзначное число: ');
readln(a);
writeln('Результат: ',(a mod 100)*10+(a div 100));
end.
var a,b,c:integer;
begin
writeln('Введите a,b,c');
write('a=');
readln(a);
write('b=');
readln(b);
write('c=');
readln(c);
if a+b>b+c then
begin
if a+b>a+c then
write('a+b=',a+b)
else
write('c+a=',c+a);
end
else if b+c>=a+b then
begin
if b+c>c+a then
write('b+c=',b+c)
else
write('c+a=',c+a);
end
else
write('c+b=',c+b);
end.
K := 2;
while k <= N do begin
writeln ( A[k] );
k:=k+2;
<span>end;
</span>