По разделам

 

Решение задачи Series 3


Даны десять вещественных чисел. Найти их среднее арифметическое.

Код (C/C++)

#include <bits/stdc++.h>
using namespace std;

int main() {
	srand((int)time(0));
	int N = 10;
	cout << "N = " << N << endl;
	
	float s = 0.0;
	float x;
	for(int i = 0; i < N; i++) {
		x = rand() % 10 - 5;
		cout << x << " ";
		//cin >> x;
		s += x;
	}
	
	cout << endl;
	cout << "Sum = " << s << endl;
	cout << "Average = " << s/N << endl;

	return 0;
}

Код (Python)

import random

N = 10
s = 0
for i in range(N):
    x = random.randrange(5)
    #x = random.uniform(1, 10)
    print(x, end="; ")
    s += x
print()
print('Sum = ', s)
print('Avg = ', s/N)
									

Код (Pascal)

program Series3;
var
  R,Rez:Real;
  i:Integer;
 
begin
  Rez:=0;
  for i:=1 to 10 do
   begin
     Write('Введите ',i,' число: ');
     Readln(R);
     Rez:=Rez+R;
   end;
  Rez:=Rez/10;
  Writeln(Rez);
end.
									




Series. Абрамян
Series 1 Просмотров: 4448
Series 2 Просмотров: 2276
Series 3 Просмотров: 2038
Series 4 Просмотров: 2223
Series 5 Просмотров: 2096
Series 6 Просмотров: 2679
Series 7 Просмотров: 2938
Series 8 Просмотров: 3229
Series 9 Просмотров: 1915
Series 10 Просмотров: 2368
Series 11 Просмотров: 1783
Series 12 Просмотров: 2136
Series 13 Просмотров: 1560
Series 14 Просмотров: 1452
Series 15 Просмотров: 1743
Series 16 Просмотров: 2148
Series 17 Просмотров: 1961
Series 18 Просмотров: 2787
Series 19 Просмотров: 2494
Series 20 Просмотров: 1545
Series 21 Просмотров: 1713
Series 22 Просмотров: 1657
Series 23 Просмотров: 2058
Series 24 Просмотров: 1891
Series 25 Просмотров: 1458
Series 26 Просмотров: 1297
Series 27 Просмотров: 1227
Series 28 Просмотров: 1171
Series 29 Просмотров: 1194
Series 30 Просмотров: 1233
Series 31 Просмотров: 1189
Series 32 Просмотров: 1707
Series 33 Просмотров: 981
Series 34 Просмотров: 1030
Series 35 Просмотров: 1408
Series 36 Просмотров: 1520
Series 37 Просмотров: 951
Series 38 Просмотров: 1272
Series 39 Просмотров: 900
Series 40 Просмотров: 1249

Комментарии

Чтобы написать комментарии вам нужно войти в систему или зарегистрироваться



Заявка на расчет