#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
ld average(ld a, ld b, ld c){
return (a+b+c)/3;
}
signed main(){
cout << average(1, 2, 3) << "\n";
cout << average(100, 50, 3) << "\n";
cout << average(9865, 678, 665);
}
using System;
namespace znanja
{
class Program
{
static void Main(string[] args)
{
int num = int.Parse(Console.ReadLine());
int[] array = new int[num];
array = Array.ConvertAll(Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries), int.Parse);
int count = 0;
for (int i = 0; i < num; i++)
{
if (array[i] > 0) count++;
}
Console.WriteLine(count);
}
}
}
Поделитесь своими знаниями, ответьте на вопрос:
В игре у трёх ребят разное количество очков. Давай посчитаем, а сколько у них очков в среднем? В программе три раза вызывается функция average с разными параметрами. Дополни код определением функции average, которая должна печатать среднее арифметическое переданных ей параметров. Среднее арифметическое = сумма слагаемых / количество слагаемых average(1, 2, 3) average(100, 50, 3) average(9865, 678, 665)
1) Python
def average(x, y, z):
return float((int(x) + int(y) + int(z)) / 3)
2) Pascal
function average(x, y, z: integer): real;
begin
average:= (x+y+z)/3;
end.
Объяснение:
1) На питоне
2) На паскале
функция должна присваиваться переменной!