Pascall
uses crt,graphABC;
var w:char;
xc,yc,c,x,y,i:integer;
begin
hidecursor;
repeat
clrscr;
writeln('Выберите фигуру');
writeln('1-треугольник');
writeln('2-квадрат');
writeln('3-круг');
writeln('4-ромб');
writeln('5-эллипс');
writeln('другое - выход');
read(w);
xc:=windowwidth div 2;
yc:=windowheight div 2;
setpencolor(clRed);
case w of
'1':begin
clrscr;
textout(xc-50,10,'Нажмите Enter');
moveto(xc+round(150*cos(pi/2)),yc-round(150*sin(pi/2)));
for i:=1 to 4 do
begin
x:=xc+round(150*cos((i-1)*(2*pi/3)+pi/2));
y:=yc-round(150*sin((i-1)*(2*pi/3)+pi/2));
lineto(x,y);
end;
readln
end;
'2':begin
clrscr;
textout(xc-50,10,'Нажмите Enter');
rectangle(xc-150,yc-150,xc+150,yc+150);
readln
end;
'3':begin
clrscr;
textout(xc-50,10,'Нажмите Enter');
circle(xc,yc,150);
readln
end;
'4':begin
clrscr;
textout(xc-50,10,'Нажмите Enter');
moveto(xc-100,yc);
lineto(xc,yc-150);
lineto(xc+100,yc);
lineto(xc,yc+150);
lineto(xc-100,yc);
readln
end;
'5':begin
clrscr;
textout(xc-50,10,'Нажмите Enter');
ellipse(xc-150,yc-100,xc+150,yc+100);
readln
end;
end;
until not(w in ['1'..'5'])
end.
class Finder:
def __init__(self):
self.current_range = range(1, 101)
def condition(self, user_select):
if user_select == '1':
return True
elif user_select == '2':
self.current_range = range(int(self.current_half + self.current_range.start), self.current_range.stop)
return False
elif user_select == '3':
self.current_range = range(self.current_range.start, int(self.current_half + self.current_range.start))
return False
@property
def current_half(self) -> int:
return int((self.current_range.stop - self.current_range.start) / 2)
finder = Finder()
while True:
user_select = input(f'Это {finder.current_half + finder.current_range.start}?\n')
result = finder.condition(user_select)
if result:
break
var x:array[1..10]of real;
i:integer;min,max:real;
begin
clrscr;min:=9999999;max:=-9999999;
for i:=1 to 10 do
begin x[i]:=exp(i*(-1))*(sqr(i)-3*i);
if x[i]<min then min:=x[i];
if x[i]>max then max:=x[i];
writeln(x[i]:1:5);
end;
writeln('измененный массив с максимальным=',max:1:5,' и минимальным=',min:1:5);
for i:=1 to 10 do
begin
if x[i]=min then writeln(max:1:5);
if x[i]=max then writeln(min:1:5);
if (x[i]<>min)and(x[i]<>max)then writeln(x[i]:1:5);
end;
end.