Hi, cprogramming forum!

I am working on a really basic war card game in my free time and was hoping you folks could help me! Currently, I just have a basic counter and working on the tie system. However, currently the tie system continue to repeats the three cards, for instance

Code:

Player 1 || Player 2
17 17
17 17
17 17

I was thinking this could be because of the card shuffle itself, but I think it might be just my bad do loop handling. I know my code is messy, but I understand it

I use gedit with g++ compiler. I have used Kate in the past (so the lines are more organized and nested)

Thanks for the help.

Source Download

Code:

//Written by Kevin Murphy 2012 //War card game is where two people play and if one card is greater that player gets the card. If they both tie, depending on how one plays, the two players throw down three more cards and the fourth car decides who gets that stash! #include <iostream> #include <stdlib.h> #include <time.h> using namespace std; int main() { system("clear"); int cards[52][2];//Creates 2 arrays for cards int x,y,currentcard,currentsuit,random,temp,player1=0,player2=0,numberofcards,ties=0,tie_cards,tie_count=0; string next; for (x=0;x<52;x++) for (y=0;y<2;y++) { cards[x][y] = x + 1; //Fills both arrays with 52 "cards" } // //Randomize the cards //Deck 1 for (x=0;x<52;x++) { random=rand()%52;//Random numbers of 52, set to random temp=cards[random][0];//sets cards random (the array random) into a temp. cards[random][0]=cards[x][0];//flips cards[x][0]=temp;//the cards } //Deck 2 for (x=0;x<52;x++) { random=rand()%52;//Random numbers of 52, set to random temp=cards[random][1];//sets cards random (the array random) into a temp. cards[random][1]=cards[x][1];//flips cards[x][1]=temp;//the cards } //Randomize the cards // do { for (x=0;x<52;x++) { //usleep(250000); system("clear"); cout<<"||Player 1: "<<player1<<"||Player 2: "<<player2<<"||Ties:"<<ties<<"||"<<endl; cout<<"||"<<cards[x][0]<<"||"<<cards[x][1]<<"||"<<endl;//Prints out the cars (from each deck) if (cards[x][0]>cards[x][1]) { player1++; numberofcards--; } if (cards[x][0]<cards[x][1]) { player2++; numberofcards--; } if (cards[x][0]==cards[x][1]) { do { cout<<"||"<<cards[x][0]<<"||"<<cards[x][1]<<"||"<<endl;//Prints out the cars (from each deck) numberofcards--; tie_count++; } while (tie_count<3); cout<<"||"<<cards[x][0]<<"||"<<cards[x][1]<<"||"<<endl;//Prints out the cars (from each deck) ties++; } } } while (numberofcards<52); return 0; }