По разделам

 

Решение задачи For 8


Даны два целых числа A и B (A < B). Найти произведение всех целых
чисел от A до B включительно.

Код (C/C++)

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

int main() {
	srand((int)time(0));
	int A, B;
	A = rand() % 10;
	B = A + (rand() % 10 + 1);
	cout << "Number A: " << A << endl;
	cout << "Number B: " << B << endl;
	
	long product = 1;
	for(int i = A; i <= B; i++) {
		product *= i;
		cout << i <<" : " << product << endl;
	}
	cout << "Product = " << product << endl;
	return 0;
}

Код (Python)

import random

A = random.randrange(10)
n = random.randrange(10)+1
B = A + n
print('A = ', A)
print('B = ', B)

P = 1
for i in range(A,B+1,1):
    P *= i
    print(i," : ",P)
print("Product = ",P)
									

Код (Pascal)

program For8;
var
A,B,Rez,  i:Integer;
 
begin
 Write('Введите A: ');
 Readln(A);
 Write('Введите B: ');
 Readln(B);
 rez:=1;
 For i:=A  to B do Rez:=Rez*i;
 Writeln(Rez);
end.
									




For. Абрамян
For 1 Просмотров: 12679
For 2 Просмотров: 10239
For 3 Просмотров: 7695
For 4 Просмотров: 7271
For 5 Просмотров: 7701
For 6 Просмотров: 7289
For 7 Просмотров: 7473
For 8 Просмотров: 6244
For 9 Просмотров: 4750
For 10 Просмотров: 6231
For 11 Просмотров: 6378
For 12 Просмотров: 6181
For 13 Просмотров: 59290
For 14 Просмотров: 4748
For 15 Просмотров: 5603
For 16 Просмотров: 5831
For 17 Просмотров: 5113
For 18 Просмотров: 4229
For 19 Просмотров: 4222
For 20 Просмотров: 4675
For 21 Просмотров: 3365
For 22 Просмотров: 4931
For 23 Просмотров: 6130
For 24 Просмотров: 3518
For 25 Просмотров: 3166
For 26 Просмотров: 2866
For 27 Просмотров: 3489
For 28 Просмотров: 2406
For 29 Просмотров: 2287
For 30 Просмотров: 3503
For 31 Просмотров: 2729
For 32 Просмотров: 2382
For 33 Просмотров: 2853
For 34 Просмотров: 3222
For 35 Просмотров: 3135
For 36 Просмотров: 3541
For 37 Просмотров: 2716
For 38 Просмотров: 2946
For 39 Просмотров: 2978
For 40 Просмотров: 3362

Комментарии

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



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