Letting user access array

Hi guys, I am doing the airplane array problem, I will put what I have done below to show whats up. I am trying to add a row number before each line of an array printed out, and it's not working like I wanted to. Also, later I have to be able to have a user input a choice (from different sections), and I was wondering if I could get a clue on how to take their input and compare to a value from a specific component of an array. (example: if theirvariable = *
cout " That seat is available"
else "seat is not available."
I'm just learning arrays in c++ and the book says aggregate operations are not allowed, so is that even possible to do here? Also, when I tried to put empty characters between each character the compiler wouldnt allow that, was wondering if anybody would know why, since ' ' is a character, even if its just an empty space.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 #include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    char again = 'Y';
     char seating [13][11] = {{'*','*','x','*','x','x'},
                            {'*','x','*','x','*','x'},
                            {'*','*','x','x','*','x'},
                            {'x','*','x','*','x','x'},
                            {'*','x','*','x','*','*'},
                            {'*','x','*','*','*','x'},
                            {'x','*','*','*','x','x'},
                            {'*','x','*','x','x','*'},
                            {'x','*','x','x','*','x'},
                            {'*','x','*','x','x','x'},
                            {'*','*','x','*','x','*'},
                            {'*','*','x','x','*','x'},
                            {'*','*','*','*','x','*'}};


   while (again == 'y' || again == 'Y')
   {

     cout << "This is the seating chart. "<<endl;
    cout << " * means seat is available, x means it is not. "<<endl;
    cout << " ABCDEF "<<endl;

       for  (int rownum = 0; rownum < 13; rownum++)
       {
           for (int row =0; row <13; row++)
           {

            for (int column = 0; column < 11; column ++)
           {

                   cout <<rownum<< seating[row][column];
           }
           }
        cout<<endl;
    }


    cout << "Would you like to do more? "<<endl;
    cin>>again;
   }
    return 0;
}
Last edited on
You need only 2 loops for the output:
1
2
3
4
5
6
7
8
9
10
11
    cout << "     A B C D E F" << endl;

    for (int row = 0; row < 13; row++)
    {
      cout<< setw(3) << left << row << ": ";
      for (int col = 0; col < 11; col++)
      {
        cout << seating[row][col] << ' ';
      }
      cout << endl;
    }


This is the seating chart.
 * means seat is available, x means it is not.
     A B C D E F
0  : * * x * x x
1  : * x * x * x
2  : * * x x * x
3  : x * x * x x
4  : * x * x * *
5  : * x * * * x
6  : x * * * x x
7  : * x * x x *
8  : x * x x * x
9  : * x * x x x
10 : * * x * x *
11 : * * x x * x
12 : * * * * x *
That made the spacing perfect, thank you.
Topic archived. No new replies allowed.