a = [] with open('input.txt', 'r') as f: n = int(f.readline()) for i in range(n): inp = f.readline() x, y = list(map(int, inp.split())) a.append((x, y))
k = 0 for i in range(n - 1): for j in range(i + 1, n): if (a[i][0] == a[j][0]) or (a[i][0] == a[j][1]) or (a[i][1] == a[j][0]) or (a[i][1] == a[j][1]): k += 1 with open('output.txt, w') as f: f.write(k) https://pastebin.com/sHe7sFyc - тут все отформатировано красиво(просто на знаниях неудобно вставлять код)
Program n_5; var a, b, c: real; procedure n_1; begin if ((a<b) and (a>c)) or ((a<c) and (a>b)) then write (a) else if ((b<a) and (b>c)) or ((b<c) and (b>a)) then write (b) else if ((c<a) and (c<b)) or ((c<b) and (c>a)) then write (c); end; begin writeln ('Введите три трёхзначных числа'); readln (a); readln (b); readln (c); if ((a >= 100) and (a <= 999) and (a <> b) and (a <> c)) and ((b >= 100) and (b <= 999) and (b <> a) and (b <> c)) and ((c >= 100) and (c <= 999) and (c <> a) and (c <> b)) then n_1 else write ('ERROR'); end.
with open('input.txt', 'r') as f:
n = int(f.readline())
for i in range(n):
inp = f.readline()
x, y = list(map(int, inp.split()))
a.append((x, y))
k = 0
for i in range(n - 1):
for j in range(i + 1, n):
if (a[i][0] == a[j][0]) or (a[i][0] == a[j][1]) or (a[i][1] == a[j][0]) or (a[i][1] == a[j][1]): k += 1
with open('output.txt, w') as f:
f.write(k)
https://pastebin.com/sHe7sFyc - тут все отформатировано красиво(просто на знаниях неудобно вставлять код)
var
a, b, c: real;
procedure n_1;
begin
if ((a<b) and (a>c)) or ((a<c) and (a>b)) then
write (a)
else
if ((b<a) and (b>c)) or ((b<c) and (b>a)) then
write (b)
else
if ((c<a) and (c<b)) or ((c<b) and (c>a)) then
write (c);
end;
begin
writeln ('Введите три трёхзначных числа');
readln (a);
readln (b);
readln (c);
if ((a >= 100) and (a <= 999) and (a <> b) and (a <> c)) and ((b >= 100) and (b <= 999) and (b <> a) and (b <> c)) and ((c >= 100) and (c <= 999) and (c <> a) and (c <> b)) then n_1
else
write ('ERROR');
end.