Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- #include <iomanip>
- using namespace std;
- int main()
- {
- srand(time(0));
- bool a1=0;
- bool a6=0;
- bool b1=0;
- bool b6=0;
- bool c1=0;
- bool c6=0;
- bool d1=0;
- bool d6=0;
- bool koniec=0;
- int A=0;
- int B=0;
- int C=0;
- int D=0;
- int X, a, b, c, d;
- cout<<"Podaj wielkosc pola gry: ";
- cin>>X;
- while(koniec!=1)
- {
- a=rand()%6+1;
- b=rand()%6+1;
- c=rand()%6+1;
- d=rand()%6+1;
- if(a1==1&&a6==1)
- {
- A+=a;
- }
- else if(a==1)
- {
- a1=1;
- }
- else if(a1==1&&a==6)
- {
- a6=1;
- }
- else
- {
- a1=0;
- a6=0;
- }
- if(b1==1&&b6==1)
- {
- B+=b;
- }
- else if(b==1)
- {
- b1=1;
- }
- else if(b1==1&&b==6)
- {
- b6=1;
- }
- else
- {
- b1=0;
- b6=0;
- }
- if(c1==1&&c6==1)
- {
- C+=c;
- }
- else if(c==1)
- {
- c1=1;
- }
- else if(c1==1&&c==6)
- {
- c6=1;
- }
- else
- {
- c1=0;
- c6=0;
- }
- if(d1==1&&d6==1)
- {
- D+=d;
- }
- else if(d==1)
- {
- d1=1;
- }
- else if(d1==1&&d==6)
- {
- d6=1;
- }
- else
- {
- d1=0;
- d6=0;
- }
- cout<<setw(3)<<" < "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
- cout<<setw(3)<<" P "<<A<<" "<<B<<" "<<C<<" "<<D<<endl;
- if(A>X||B>X||C>X||D>X)
- {
- koniec=1;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement