Topic:
Initial 6 hands in each person's hands
Code:
#include <iostream>using namespacestd;structhand{intnum[ +]; intHead,tail;} b;intMain () {intRace=0; A.head=b.head=1; A.tail=7; b.tail=7; intt[Ten]={0},last=0, card; BOOLbook[Ten]={0}; for(intI=1; i<=6; i++) cin>>A.num[i]; for(intI=1; i<=6; i++) cin>>B.num[i]; while(a.head<a.tail&&b.head<b.tail) {race++; Card=A.num[a.head]; if(book[card]==0) { last++;t[last]=Card; A.head++;book[card]=1; } Else{A.head++;a.num[a.tail]=Card; A.tail++; while(t[last]!=card) {A.num[a.tail]=T[last]; A.tail++;book[t[last]]=0; Last--; }} Card=B.num[b.head]; if(book[card]==0) { last++;t[last]=Card; B.head++;book[card]=1; } Else{B.head++;b.num[b.tail]=Card; B.tail++; while(t[last]!=card) {B.num[b.tail]=T[last]; B.tail++;book[t[last]]=0; Last--; } } if(race== -&&a.head<a.tail&&b.head<b.tail) {cout<<"Draw"<<endl<<"little Hum The hand is now"; for(inti=a.head;i<a.tail;i++) cout<<" "<<A.num[i]; cout<<endl<<"the hand of Little Kazakhstan is now"; for(inti=b.head;i<b.tail;i++) cout<<" "<<B.num[i]; if(last>0) {cout<<endl<<"the cards on the table are"; for(intI=1; i<=last;i++) cout<<" "<<T[i]; } Elsecout<<endl<<"There's no cards on the table."; } } if(a.head<a.tail) {cout<<"Little Hum win"<<endl<<"little Hum The hand is now"; for(inti=a.head;i<a.tail;i++) cout<<" "<<A.num[i]; } Else{cout<<"Xiao Ha win"<<endl<<"the hand of Little Kazakhstan is now"; for(inti=b.head;i<b.tail;i++) cout<<" "<<B.num[i]; } if(last>0) {cout<<endl<<"the cards on the table are"; for(intI=1; i<=last;i++) cout<<" "<<T[i]; } Elsecout<<endl<<"There's no cards on the table."; }
Kitten Fishing Game (C + + implementation)