[*] Общее количество единиц < /p>
< /li>
Арендная плата за занимать все единицы
Увеличение арендной платы, которое приведет к вакантной единице < Br /> < /li>
Стоимость обслуживания арендованной единицы < /p>
< /li>
< /ol>
и вернуть количество единиц, которые будут Максимизируйте прибыль. < /p>
Код: Выделить всё
# include
using namespace std;
void maximise(int tU, double rM, double rI, double mC) { // shortened version of totalUnits, rentMax, rentIncrease, maintainCost
double maxProfit = 0; // the max profit
int maxUnits; // the number of units to max the profit
for (int i=0; i maxProfit) { // if the profit is more than the maxProfit
maxProfit = profit; // change the maxProfit to current profit
maxUnits = i; // and the maximum number of units to i
}
}
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79461834/why-is-my-c-code-not-outputting-the-correct-profit[/url]
Мобильная версия