Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- // 1. Data
- int decoyMoney = 50;
- int maxDecoyStack = 1;
- int flashMoney = 200;
- int maxFlashStack = 2;
- int nadeMoney = 300;
- int maxNadeStack = 1;
- int smokeMoney = 300;
- int maxSmokeStack = 1;
- int molotovMoney = 400;
- int maxMolotovStack = 1;
- int maxStack = 4;
- // 2. For-loops
- cout << "******** All the combinations analyzed ********" << endl;
- vector <int> singleMoneySpent = vector <int> ();
- for(int decoys=0; decoys<=maxDecoyStack; decoys++){
- for(int flashes=0; flashes<=maxFlashStack; flashes++){
- for(int nades=0; nades<=maxNadeStack; nades++){
- for(int smokes=0; smokes<=maxSmokeStack; smokes++){
- for(int molotovs=0; molotovs<=maxMolotovStack; molotovs++){
- // If-case for stacks
- if(decoys+flashes+nades+smokes+molotovs <= maxStack){
- int moneySpent = decoys*decoyMoney + flashes*flashMoney + nades*nadeMoney + smokes*smokeMoney + molotovs*molotovMoney;
- // Check if this value of money is in my unique list
- if(singleMoneySpent.size() == 0){
- singleMoneySpent.push_back(moneySpent);
- }
- else{
- bool isElementInList = false;
- for(int j=0; j<singleMoneySpent.size(); j++){
- if(moneySpent == singleMoneySpent[j]){
- isElementInList = true;
- break;
- }
- }
- if(isElementInList == false){
- singleMoneySpent.push_back(moneySpent);
- }
- }
- cout << "Money spent = " << moneySpent << " ----> " << decoys << " decoys, " << flashes << " flashes, " << nades << " nades, " << smokes << " smokes, " << molotovs << " molotovs.\n";
- }
- }
- }
- }
- }
- }
- // 3. Now, I have the list with all the possible values, after sorting the elements
- cout << "\n\n******** All the possible values ********\n";
- sort(singleMoneySpent.begin(), singleMoneySpent.end());
- for(int i=0; i<singleMoneySpent.size(); i++){
- cout << "Value " << (i+1) << ": " << singleMoneySpent[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement