#include #include const MAX = 150; int trucks = 40; int numWheels = 10; int weeks = 20; int viewWeek = 3; int k1 = 5; int k2 = 10; int k3 = 25; int k4 = 30; int k5 = 30; int round(double num) { int result = num; if (num - result >= 0.5) result++; return result; } void inputData() { cout << "Number of trucks:"; cin >> trucks; cout << "Number of truck's wheels:"; cin >> numWheels; cout << "Number of weeks:"; cin >> weeks; cout << "Number of weeks between view:"; cin >> viewWeek; cout << "Damaging wheels 6000km:"; cin >> k1; cout << "Damaging wheels 12000km:"; cin >> k2; cout << "Damaging wheels 18000km:" ; cin >> k3; cout << "Damaging wheels 24000km:" ; cin >> k4 ; cout << "Damaging wheels 30000km:"; cin >> k5; } void main() { randomize(); clrscr(); inputData(); int q100 = trucks * numWheels; int q80 = 0; int q60 = 0; int q40 = 0; int q20 = 0; int sum = k1 + k2 + k3 + k4 + k5; int d1 = round((double)k1 / sum / 3 * 100); sum -= k1; int d2 = round((double)k2 / sum / 3 * 100); sum -= k2; int d3 = round((double)k3 / sum / 3 * 100); sum -= k3; int d4 = round((double)k4 / sum / 3 * 100); int damage, i, newWheels = 0; int lost1, lost2, lost3, lost4; for (int week = 1; week <= weeks; week++) { lost1 = lost2 = lost3 = lost4 = 0; for (int k = 0; k < MAX; k++) { damage = 0; for (i = 0; i < q100; i++) if (random(100) < d1) damage++; lost1 += damage; damage = 0; for (i = 0; i < q80; i++) if (random(100) < d2) damage++; lost2 += damage; damage = 0; for (i = 0; i < q60; i++) if (random(100) < d3) damage++; lost3 += damage; damage = 0; for (i = 0; i < q40; i++) if (random(100) < d4) damage++; lost4 += damage; } lost1 /= MAX; lost2 /= MAX; lost3 /= MAX; lost4 /= MAX; q100 -= lost1; q80 -= lost2; q60 -= lost3; q40 -= lost4; if (week % 3 == 0) { q20 = q40; q40 = q60; q60 = q80; q80 = q100; q100 = trucks*numWheels - q80 - q60 - q40 - q20; newWheels += q100; } if (week % viewWeek == 0) { { newWheels += trucks*numWheels - q100 - q80 - q60 - q40 - q20; } cout << "Week N" << week << ": " << newWheels << " - new wheels" << endl; if (getch() == 27) break; newWheels = 0; } } }