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
Var N:Array[1..20] of integer; i,j,q,k,max:integer;begin Randomize;writeln('массив');for i:=1 to 20 do beginN[i]:= random(100)-50;write(N[i]:4);end;writeln;i:=0;writeln('Измененый массив');While j<20 do beginj:= j + 2; k := N[j-1];N[j-1]:=N[j]; N[j]:= k;end;foreach q in N do beginwrite(q :4);end;end.
var N,M:Array[1..20] of integer; i,j,min,q,k,max:integer;begin Randomize;max:=-200; min:=200;writeln('1 массив');for i:=1 to 20 do beginN[i]:= random(100)-50;write(N[i]:4);if ((N[i]>0 )and(N[i] mod 2 = 0))then beginif max < N[i] then max := N[i];if min > N[i] then min := N[i];j:= j + 1;M[j]:=N[i];end;end;writeln;writeln('2 массив');foreach k in M do beginwrite(k:4);end;writeln;if (max = -200) or (min = 200) then write ('нет чётных положительных элементов')else beginwrite('max = ' ,max:4);write(' min = ' ,min:4);end;end.
Program koordunatu;
Var
x,y:real;
Begin
Write( 'x=>' );
readln(x);
Write( 'y=>' );
readln(y);
if (x=0) and (y=0) then
writeln('M(0,0)')
else
if x=0 then
writeln('OY')
else
if y=0 then
writeln('OX');
if (x>0) and (y>0) then writeln('І');
if (x<0) and (y>0) then writeln('II');
if (x<0) and (y<0) then writeln('III');
if (x>0) and (y<0) then writeln('IV')
End.