// PascalABC.NET 3.1, сборка 1230 от 27.04.2016 begin var s:=ReadLines('in.txt').ToArray; var n:=StrToInt(s[0]); var a:=s[1].ToWords.Select(e->StrToInt(e)).ToArray; var f:=OpenWrite('out.txt'); Writeln(f,n,' - (кол-во чисел)'); foreach var e in a do Write(f,e,' '); Writeln(f); Writeln(f,'Среднее значение четных ', a.Where(x->x.IsEven).Average); Writeln(f,'Среднее значение нечетных ', a.Where(x->x.IsOdd).Average); f.Close end.
Возможный вариант в C++ #include <iostream> int main() { using namespace std; int N; cout << "Enter N: "; cin >> N; int num; int max = 1; int i; for (i = 0; i < N; ++i) { cout << "Enter #" << i + 1 << " number: "; cin >> num; if ((num - 9) % 10 != 0 && num % 3 == 0) { max = num; break; } } for (int j = i + 1; j < N; ++j) { cout << "Enter #" << j + 1 << " number: "; cin >> num; if ((num - 9) % 10 != 0 && num % 3 == 0) if (num > max) max = num; } if (max != 1) cout << "Max number div by 3 and don't end 9: " << max << endl; else cout << "No numbers div by 3 and don't end 9" << endl; return 0; }
a = list(range(11))
print(*a)
n = len(a)
while n > 0:
print(a[(len(a) - n) // 2], end=" ")
if n > 1:
print(a[(len(a) + n) // 2 - 1], end = " ")
n -= 2
print()