View Single Post
Old 12-08-2005, 08:18 AM   #7 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Using my code you could build your own around it:
Code:
#include <iostream>
#include <cstring>

using std::endl;
using std::cout;

//--
const unsigned ROWS = 7;
const unsigned COLS = 4;
static char seat[7][COLS+1] = {0}; //COLS+1 for terminating character.
//--

int main()
{
  for(unsigned i = 0; i < ROWS; ++i)
  {
    std::strcpy(seat[i], "ABCD");
  }
  
  for(unsigned i = 0; i < ROWS; ++i)
  {
    cout<<seat[i]<<endl;
  }
  
  //Let's take seat at position [3,2]. Since indexes start at 0 we need to
  //substract 1: position = [3-1][2-1].
  seat[2][1] = 'X';
  
  cout<<std::endl<<"After taking a seat:"<<endl<<endl;
  
  for(unsigned i = 0; i < ROWS; ++i)
  {
    cout<<seat[i]<<endl;
  }
  return 0;
}
__________________
Valmont is offline   Reply With Quote