PascalABC.NET
begin
var (a, b, c) := ReadInteger3('Введи три числа:');
if a < b then
Swap(a, b);
if c > b then
begin
Swap(b, c);
if b > a then
Swap(a, b)
end;
Print(a, b, c)
end.
#include <iostream>
int main() {
const int SIZE = 10;
bool isSence = false;
int sum = 0;
int count = 0;
int arr[SIZE];
for (int i = 0; i < SIZE; i++)
{
arr[i] = rand() % 20 - 10; // "рандомно" заполняем массив от -10 до 10
std::cout << arr[i] << "\t"; // выводим массив в консоль
if (arr[i] >= 0)
isSence = true;
}
for (int i = 0; i < SIZE; i++)
{
if ((isSence) && (arr[i] > 0))
sum += arr[i]; //sum = sum + arr[i];
count++;
}
if (isSence)
std::cout << "\nсреднее арифметическое положительных чисел = " << double(sum) / count << std::endl; // явное приведение типов
else
std::cout << "\nВ массиве нету положительных чисел или нету нулей и/или отрицательных чисел" << std::endl;
return 0;
}
a, b, c = int(input()), int(input()), int(input())
if a >= b and a >= c and b >= c:
print(c, b, a)
elif a <= b and a >= c and b >= c:
print(c, a, b)
elif a <= b and a <= c and b <= c:
print(a, b, c)
elif a >= b and a >= c and b <= c:
print(b, c, a)
elif a >= b and a <= c and b <= c:
print(b, a, c)
else:
print(a, c, b)
Объяснение:
Это Python