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.
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
struct PifaThree
{
int a;
int b;
int c;
PifaThree()
{
a = 0;
b = 0;
c = 0;
}
PifaThree(int a_, int b_, int c_) : a(a_), b(b_), c(c_)
{
}
~PifaThree() {}
void show()
{
std::cout << a << "^2 = " << b << "^2 + " << c << "^2";
}
};
int main()
{
std::vector<int> arr;
std::vector<int> sq_arr;
std::vector<PifaThree> results;
int temp = 0;
while(std::cin >> temp) //прерывается вводом не-int чего-нибудь
{
arr.push_back(temp);
}
if(arr.size() < 3)
{
std::cout << "3 or more needs";
system("pause");
return 0;
}
std::sort(arr.begin(), arr.end(), [](int a, int b){ return abs(a) > abs(b); } );
for(auto iter = arr.begin(); iter!= arr.end(); ++iter) sq_arr.push_back(*iter * *iter);
for(size_t i = 0, l = sq_arr.size() - 2; i < l; ++i)
{
size_t j = i+1;
int half = sq_arr[i] / 2;
while( j < l+1 && sq_arr[j] >= half)
{
size_t k = j+1;
int a = sq_arr[j] + sq_arr[k];
while( k < l+2 && a >= sq_arr[i] )
{
if(a == sq_arr[i])
{
results.push_back( PifaThree(arr[i], arr[j], arr[k]) );
}
++k;
a = sq_arr[j] + sq_arr[k];
}
++j;
}
}
std::cout << "\n\n";
for(auto iter = arr.begin(); iter!= arr.end(); ++iter) std::cout << " " << *iter;
/*
std::cout << "\n";
for(auto iter = sq_arr.begin(); iter!= sq_arr.end(); ++iter) std::cout << " " << *iter;
*/
std::cout << "\n\n";
for(auto iter = results.begin(); iter!= results.end(); ++iter)
{
iter->show();
std::cout << "\n";
}
system("pause");
return 0;
}
ответ: Если я тебя правильно понял, то вот код на python
text = input()
print('1 2 3\n' + text + '\n3 2 1')