Advertisement
Spocoman

AND Processors

Sep 15th, 2023
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int neededProcessors, workers, days, dayliWorkingHours = 8, processorBuildHours = 3;
  7.     cin >> neededProcessors >> workers >> days;
  8.  
  9.     double processorPrice = 110.10;
  10.  
  11.     double diff = (neededProcessors - floor(workers * days * dayliWorkingHours / processorBuildHours)) * processorPrice;
  12.  
  13.     if (diff > 0) {
  14.         printf("Losses: -> %.2f BGN\n", diff);
  15.     }
  16.     else {
  17.         printf("Profit: -> %.2f BGN\n", abs(diff));
  18.     }
  19.     return 0;
  20. }
  21.  
  22. Или леко тарикатската с тернарен оператор:)
  23.  
  24. #include <iostream>
  25.  
  26. using namespace std;
  27.  
  28. int main() {
  29.     int neededProcessors, workers, days;
  30.     cin >> neededProcessors >> workers >> days;
  31.  
  32.     double diff = (neededProcessors - workers * days * 8 / 3) * 110.10;
  33.  
  34.     printf("%s: -> % .2f BGN\n",diff > 0 ? "Losses" : "Profit", abs(diff));
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement