Kitten Fishing Game (C + + implementation)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.