Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- srand(time(0));
- int run = 1;
- int HT = 0;
- int rolls = 0;
- int rows = 0;
- int Roll1=0; int Roll2=0;
- string input = "" ;
- do {
- while (true){ ;
- cout<<"heads or tails?"<<endl<<endl<<"type 1 for heads, or 2 for tails:"<<endl;
- cin>>HT;
- if (HT==1||HT==2)
- break ;
- cout<<endl<<"only 1s and 2s you silly goose"<<endl<<endl<<"try again:"<<endl<<endl;
- }
- if (HT==1){cout<<endl<<"you chose Heads"<<endl<<endl;}
- if (HT==2){cout<<endl<<"you chose Tails"<<endl<<endl;}
- while (true){ ;
- cout<<"enter number of flips:";
- cin>>rolls;
- if (rolls<=1000000)
- break ;
- cout<<"please enter valid number under or equal to 1000000:"<<endl;
- }
- cout<<endl<<rolls<<" Total flips"<<endl<<endl<<"good luck"<<endl<<endl;
- while (rolls>0) {
- int Ranroll = 1+(rand()&1);
- if (Ranroll == 1){Roll1++;}
- if (Ranroll == 2){Roll2++;}
- cout<<Ranroll; rows++;
- if (rows>=80){cout<<endl;rows=0;}
- rolls--;
- }
- cout<<endl;
- if (Roll1>Roll2&&HT==1){cout<<endl<<"YOU WIN"<<endl<<endl;}
- if (Roll2>Roll1&&HT==2){cout<<endl<<"YOU WIN"<<endl<<endl;}
- if (Roll1>Roll2&&HT==2){cout<<endl<<"you lose"<<endl<<endl;}
- if (Roll2>Roll1&&HT==1){cout<<endl<<"you lose"<<endl<<endl;}
- cout<<"Heads="<<Roll1<<" Tails="<<Roll2<<endl<<endl<<"Sum= "<<Roll1+Roll2<<endl<<endl<<"Try again?"<<endl<<endl;
- HT=0; Roll1=0;Roll2=0;rolls=0;
- }while(run=1);
- }
Advertisement
Add Comment
Please, Sign In to add comment