Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- //code AUTHOR:KAKA
- bool checknext(int p,vector<int> v,int i,int temp)
- {
- bool flag=true;
- int j;
- for(j=i+1;j<=temp&&j<=p+i;j++)
- {
- if(v[j]>=11||v[j]==1)
- {
- flag=false;
- break;
- }
- }
- return flag&&(j<=temp+1);
- }
- int main()
- {
- int n;
- // cin>>n;
- //int temp=n;
- vector<int> v={3,2,1,5,6,4,8,11,2,3,2,13,6,10,6};//vector is similar to array except we need not to specify its size
- /* while(n)
- {
- int dummy;
- cin>>dummy;
- v.push_back(dummy);//loading the vector or array with n cards
- n--;
- }*/
- n=v.size();
- int temp=n;
- int a=0,b=0,i=0;
- bool flag=true;
- while(n>0)
- {
- int points=0,next=1;
- cout<<v[i];
- switch(v[i]){
- case 1:checknext(4,v,i,temp)?(points=4,next=5):(points=0,next=1);break;
- case 11:checknext(1,v,i,temp)?(points=1,next=2):(points=0,next=1);break;
- case 12:checknext(2,v,i,temp)?(points=2,next=3):(points=0,next=1);break;
- case 13:checknext(3,v,i,temp)?(points=3,next=4):(points=0,next=1);break;
- }
- //cout<<points;
- if(flag)
- {
- cout<<":a"<<endl;
- a+=points;
- if(points)
- cout<<"a scores:"<<points<<endl;
- }
- else
- {
- cout<<":b"<<endl;
- b+=points;
- if(points)
- cout<<"b scores:"<<points<<endl;
- }
- n=n-next;
- i=i+next;
- flag=!flag; //toggling the chance
- }
- cout<<"a points:"<<a<<endl;
- cout<<"b points:"<<b<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement