using System namespace Lab7 class MainClass public static void Main st

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
namespace Lab7 {
class MainClass {
public static void Main(string[] args) {
double lambda = 0.4d;
Modeling(lambda);
}
public static void Modeling(double lambda) {
bool isBusy = true;
int spendTime = 0;
double queue = 0.0;
int countIncome = 0;
int countCanceled = 0;
for (int time = 0; time < 60; time++) {
if (isBusy) {
if (spendTime == 3) {
isBusy = false;
spendTime = 0;
Console.WriteLine("Человек завершил разговор");
} else {
spendTime++;
if (queue >= 1.0) {
queue = queue % (int)queue;
countCanceled++;
}
}
} else if (queue >= 1.0) {
queue = queue % (int)queue;
isBusy = true;
countIncome++;
Console.WriteLine("Человек дозвонился");
}
queue += lambda;
}
Console.WriteLine(countIncome + " " + countCanceled);
}
}
}