Advertisement
makispaiktis

CSGO Economy

Jul 18th, 2020 (edited)
1,764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     // 1. Data
  10.     int decoyMoney = 50;
  11.     int maxDecoyStack = 1;
  12.     int flashMoney = 200;
  13.     int maxFlashStack = 2;
  14.     int nadeMoney = 300;
  15.     int maxNadeStack = 1;
  16.     int smokeMoney = 300;
  17.     int maxSmokeStack = 1;
  18.     int molotovMoney = 400;
  19.     int maxMolotovStack = 1;
  20.     int maxStack = 4;
  21.  
  22.     // 2. For-loops
  23.     cout << "******** All the combinations analyzed ********" << endl;
  24.     vector <int> singleMoneySpent = vector <int> ();
  25.     for(int decoys=0; decoys<=maxDecoyStack; decoys++){
  26.         for(int flashes=0; flashes<=maxFlashStack; flashes++){
  27.             for(int nades=0; nades<=maxNadeStack; nades++){
  28.                 for(int smokes=0; smokes<=maxSmokeStack; smokes++){
  29.                     for(int molotovs=0; molotovs<=maxMolotovStack; molotovs++){
  30.                         // If-case for stacks
  31.                         if(decoys+flashes+nades+smokes+molotovs <= maxStack){
  32.                             int moneySpent = decoys*decoyMoney + flashes*flashMoney + nades*nadeMoney + smokes*smokeMoney + molotovs*molotovMoney;
  33.                             // Check if this value of money is in my unique list
  34.                             if(singleMoneySpent.size() == 0){
  35.                                 singleMoneySpent.push_back(moneySpent);
  36.                             }
  37.                             else{
  38.                                 bool isElementInList = false;
  39.                                 for(int j=0; j<singleMoneySpent.size(); j++){
  40.                                     if(moneySpent == singleMoneySpent[j]){
  41.                                         isElementInList = true;
  42.                                         break;
  43.                                     }
  44.                                 }
  45.                                 if(isElementInList == false){
  46.                                     singleMoneySpent.push_back(moneySpent);
  47.                                 }
  48.                             }
  49.                             cout << "Money spent = " << moneySpent << " ----> " << decoys << " decoys, " << flashes << " flashes, " << nades << " nades, " << smokes << " smokes, " <<  molotovs << " molotovs.\n";
  50.                         }
  51.                     }
  52.                 }
  53.             }
  54.         }
  55.     }
  56.  
  57.     // 3. Now, I have the list with all the possible values, after sorting the elements
  58.     cout << "\n\n******** All the possible values ********\n";
  59.     sort(singleMoneySpent.begin(), singleMoneySpent.end());
  60.     for(int i=0; i<singleMoneySpent.size(); i++){
  61.         cout << "Value " << (i+1) << ": " << singleMoneySpent[i] << endl;
  62.     }
  63.  
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement