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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <cctype>
#include <iomanip>
using namespace std; //Declare global Variables and Arrays and Function Prototypes
const int ASIZE = 7, RSIZE = 5;
void SeatAssign( char SArray[][RSIZE],int ASIZE,int RSIZE,int rownumber,char seatLetter);
void DisplaySeatsFN( char SeatsArray[][RSIZE],int ASIZE);
char SeatsArray[ASIZE][RSIZE];
int main() {
int rownumber, seatLetter;
//declare variables for main()
char SeatsArray[ASIZE][RSIZE] = { {'1','A','B','C','D'},
{'2','A','B','C','D'},
{'3','A','B','C','D'},
{'4','A','B','C','D'},
{'5','A','B','C','D'},
{'6','A','B','C','D'},
{'7','A','B','C','D'} }; //initialize array
SeatsArray[0][1] = 'X';
DisplaySeatsFN(SeatsArray,ASIZE);
char restart = 'y';
do {
cout << endl;
cout << endl;
cout << "Enter row number of seat you wish to reserve(1-7): ";
cin >> rownumber;
cout << "Enter letter of seat you wish to reserve(A-D): ";
cin >> seatLetter;
seatLetter = static_cast<char>(toupper(seatLetter));
//
SeatAssign(SeatsArray, ASIZE,RSIZE,rownumber,seatLetter);
//
cout << endl;
DisplaySeatsFN(SeatsArray, ASIZE);
cout << endl;
cout << "make another reservation?(y/n)";
cin >> restart;
} while (restart == 'y' || restart == 'Y');
cout << endl;
cout << endl;
return 0;
}
void SeatAssign( char SeatsArray[][RSIZE],int ASIZE,int RSIZE, int rownumber,char seatLetter) {
if (rownumber - 1 == 0)
if (seatLetter == 'A')
SeatsArray[0][1] = 'X';
if (rownumber - 1 == 0)
if (seatLetter == 'B')
SeatsArray[0][2] = 'X';
if (rownumber - 1 == 0)
if (seatLetter == 'C')
SeatsArray[0][3] = 'X';
if (rownumber - 1 == 0)
if (seatLetter == 'D')
SeatsArray[0][4] = 'X';
if (rownumber - 1 == 1)
if (seatLetter == 'A')
SeatsArray[1][1] = 'X';
if (rownumber - 1 == 1)
if (seatLetter == 'B')
SeatsArray[1][2] = 'X';
if (rownumber - 1 == 1)
if (seatLetter == 'C')
SeatsArray[1][3] = 'X';
if (rownumber - 1 == 1)
if (seatLetter == 'D')
SeatsArray[1][4] = 'X';
if (rownumber - 1 == 2)
if (seatLetter == 'A')
SeatsArray[2][1] = 'X';
if (rownumber - 1 == 2)
if (seatLetter == 'B')
SeatsArray[2][2] = 'X';
if (rownumber - 1 == 2)
if (seatLetter == 'C')
SeatsArray[2][3] = 'X';
if (rownumber - 1 == 2)
if (seatLetter == 'D')
SeatsArray[2][4] = 'X';
if (rownumber - 1 == 3)
if (seatLetter == 'A')
SeatsArray[3][1] = 'X';
if (rownumber - 1 == 3)
if (seatLetter == 'B')
SeatsArray[3][2] = 'X';
if (rownumber - 1 == 3)
if (seatLetter == 'C')
SeatsArray[3][3] = 'X';
if (rownumber - 1 == 3)
if (seatLetter == 'D')
SeatsArray[3][4] = 'X';
if (rownumber - 1 == 4)
if (seatLetter == 'A')
SeatsArray[4][1] = 'X';
if (rownumber - 1 == 4)
if (seatLetter == 'B')
SeatsArray[4][2] = 'X';
if (rownumber - 1 == 4)
if (seatLetter == 'C')
SeatsArray[4][3] = 'X';
if (rownumber - 1 == 4)
if (seatLetter == 'D')
SeatsArray[4][4] = 'X';
if (rownumber - 1 == 5)
if (seatLetter == 'A')
SeatsArray[5][1] = 'X';
if (rownumber - 1 == 5)
if (seatLetter == 'A')
SeatsArray[5][1] = 'X';
if (rownumber - 1 == 5)
if (seatLetter == 'B')
SeatsArray[5][2] = 'X';
if (rownumber - 1 == 5)
if (seatLetter == 'C')
SeatsArray[5][3] = 'X';
if (rownumber - 1 == 5)
if (seatLetter == 'D')
SeatsArray[5][4] = 'X';
if (rownumber - 1 == 6)
if (seatLetter == 'A')
SeatsArray[6][1] = 'X';
if (rownumber - 1 == 6)
if (seatLetter == 'B')
SeatsArray[6][2] = 'X';
if (rownumber - 1 == 6)
if (seatLetter == 'C')
SeatsArray[6][3] = 'X';
if (rownumber - 1 == 6)
if (seatLetter == 'D')
SeatsArray[6][4] = 'X';
}
void DisplaySeatsFN(char Seats[][RSIZE],int ASIZE) {
for (int c = 0; c < 7;c++) { //display seats (2D array)
cout << endl;
for (int r = 0;r < 5;r++) {
cout << " " << Seats[c][r];
cout << " ";
}
}
//
}
void AssignSeats(char Seats[][RSIZE], int ASIZE) {
for (int c = 0; c < 7;c++) {
for (int r = 0;r < 5;r++) {
}
}
}
|