Sponsored Content
Full Discussion: C++ Help
Top Forums Programming C++ Help Post 302274430 by Corona688 on Wednesday 7th of January 2009 02:33:54 PM
Old 01-07-2009
You're putting X-es into the array for player one, how about using 1's and 2's instead? That'll make it easier to keep track of the players.

I would declare a variable outside the loop to keep track of whose turn it is, and toggle it back and forth at the top of the loop. Here's a really bare skeleton of the idea:
Code:
int player=2;

while(! gameover)
{
  int value;

  if(player == 1)
  {
    player=2;
  }
  else 
  {
    player=1;
  }

  cout << "Player " << player << "'s turn:" << endl;
  cin >> value;
  board[value]=player;

  check_if_game_over;
}

cout << "Player " << player << " wins!" << endl;

 
TV_SORT(1p)						User Contributed Perl Documentation					       TV_SORT(1p)

NAME
tv_sort - Sort XMLTV listings files by date, and add stop times. SYNOPSIS
tv_sort [--help] [--by-channel] [--output FILE] [FILE...] DESCRIPTION
Read XMLTV data and write out the same data sorted in date order. Where stop times of programmes are missing, guess them from the start time of the next programme on the same channel. For the last programme of a channel, no stop time can be added. Tv_sort also performs some sanity checks such as making sure no two programmes on the same channel overlap. --output FILE write to FILE rather than standard output --by-channel sort first by channel id, then by date within each channel. --duplicate-error If the input contains the same programme more than once, consider this as an error. Default is to silently ignore duplicate entries. The time sorting is by start time, then by stop time. Without --by-channel, if start times and stop times are equal then two programmes are sorted by internal channel id. With --by-channel, channel id is compared first and then times. You can think of tv_sort as converting XMLTV data into a canonical form, useful for diffing two files. EXAMPLES
At a typical Unix shell or Windows command prompt: tv_sort <in.xml >out.xml tv_sort in.xml --output out.xml These are different ways of saying the same thing. AUTHOR
Ed Avis, ed@membled.com perl v5.14.2 2006-03-02 TV_SORT(1p)
All times are GMT -4. The time now is 10:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy