По разделам

 

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


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

Код (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;
	float x;
	for(int i = 0; i < N; i++) {
		//x = rand() % 20 - 10;
		//cout << x << " ";
		cin >> x;
		s += x;
	}
	
	cout << endl;
	cout << "Sum = " << s << endl;

	return 0;
}

Код (Python)

import random

s = 0
for i in range(10):
    x = random.randrange(6)
    print(x, end = " ")
    s += x
print()
print('Sum = ', s)

s = 0
for i in range(10):
    x = random.uniform(1, 100)
    print(x)
    s += x
print('Sum = ', s)
									

Код (Pascal)

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

Дополнительно

s = 0
for i in range(10):
    s += float(input())
print(s)
									



Series. Абрамян
Series 1 Просмотров: 4441
Series 2 Просмотров: 2267
Series 3 Просмотров: 2034
Series 4 Просмотров: 2217
Series 5 Просмотров: 2091
Series 6 Просмотров: 2672
Series 7 Просмотров: 2933
Series 8 Просмотров: 3227
Series 9 Просмотров: 1913
Series 10 Просмотров: 2363
Series 11 Просмотров: 1774
Series 12 Просмотров: 2129
Series 13 Просмотров: 1556
Series 14 Просмотров: 1446
Series 15 Просмотров: 1733
Series 16 Просмотров: 2145
Series 17 Просмотров: 1955
Series 18 Просмотров: 2783
Series 19 Просмотров: 2489
Series 20 Просмотров: 1539
Series 21 Просмотров: 1710
Series 22 Просмотров: 1654
Series 23 Просмотров: 2054
Series 24 Просмотров: 1885
Series 25 Просмотров: 1453
Series 26 Просмотров: 1289
Series 27 Просмотров: 1221
Series 28 Просмотров: 1169
Series 29 Просмотров: 1189
Series 30 Просмотров: 1230
Series 31 Просмотров: 1183
Series 32 Просмотров: 1702
Series 33 Просмотров: 978
Series 34 Просмотров: 1026
Series 35 Просмотров: 1405
Series 36 Просмотров: 1515
Series 37 Просмотров: 948
Series 38 Просмотров: 1267
Series 39 Просмотров: 896
Series 40 Просмотров: 1242

Комментарии

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



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