Random ran = new Random();
int N = Console.ReadLine();
int Z = Console.ReadLine();
int[] arr = new arr[N];
int sum =0;
for(int i =0; i<= arr.Length; i++) {
arr[i] = ran.Next(1, Z);
sum+=arr[i];
Console.WriteLine(sum);
}
Программа:
Python:
from random import uniform
N = int(input('N = '))
Z = float(input('Z = '))
s = 0
for i in range(1, N):
s += uniform(1, Z)
print(s)
Random ran = new Random();
int N = Console.ReadLine();
int Z = Console.ReadLine();
int[] arr = new arr[N];
int sum =0;
for(int i =0; i<= arr.Length; i++) {
arr[i] = ran.Next(1, Z);
sum+=arr[i];
Console.WriteLine(sum);
}
Программа:
Python:
from random import uniform
N = int(input('N = '))
Z = float(input('Z = '))
s = 0
for i in range(1, N):
s += uniform(1, Z)
print(s)