Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int dice_sum, edge_sum;
- class gameStart{
- string s;
- public:
- void dice_roll(string &str)
- {
- for(int j=0; j<str.find("d"); ++j){
- s +=str[j];
- }
- dice_sum = stoi(s);
- s.clear();
- for(int k=str.find("d")+1; str[k]!=NULL; ++k){
- s +=str[k];
- }
- edge_sum = stoi(s);
- }
- };
- int main()
- {
- //input
- string str;
- cout << "Roll the dice: ";
- getline(cin, str);
- gameStart gs;
- gs.dice_roll(str);
- //output
- srand(time(0));
- for (int i=0; i < dice_sum; ++i){
- cout << 1 + rand() % edge_sum << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement