c 2b 2b append into empy array

Solutions on MaxInterview for c 2b 2b append into empy array by the best coders in the world

showing results for - "c 2b 2b append into empy array"
Kellie
24 Jun 2016
1#include <iostream>
2#include <cmath>
3using namespace std;
4void Shop(int);
5
6int Gold = 10;
7
8int HealthPotion = 0;
9int ManaPotion = 0;
10
11int Choice;
12string Inventory[5];
13
14
15int main(){
16
17
18
19cout << "You are in the shop. What would you like to buy?";
20cout << " You have " << Gold << " gold.";
21cout << endl;
22cout << "1\) Health potion: 2 gold.  2\) Mana Potion: 3 gold.";
23cin >> Choice;
24Shop(Choice);
25
26cin.ignore();
27cin.get();
28return 0;
29}
30
31void Shop(int x){
32 if(x==1){
33   HealthPotion++;
34   Gold = Gold-2;
35   }
36 if(x==2){
37   ManaPotion++;
38   Gold = Gold-3;
39   }
40
41}