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
|
//adsf
#include <iostream>
#include <cctype>
#include <Windows.h>
using namespace std;
struct Seating
{
int rows;
int columns;
};
typedef int* IntArrayPtr;
typedef char* CharArrayPtr;
typedef CharArrayPtr* SeatingChartPtr;
Seating user_input();
void Initialize_Seating(SeatingChartPtr seating, int rows, int columns);
void Display_Seating(SeatingChartPtr seating, int rows, int columns);
int main()
{
Seating cht;
int rows=0, columns=0;
cht = user_input(); // cht for charts, i.e. seating chart with rows and columns
SeatingChartPtr seating = new CharArrayPtr[cht.rows];
int i, j;
for (i = 0; i < cht.rows; i++)
seating[i] = new char[cht.columns];
Initialize_Seating(seating, cht.rows, cht.columns);
Display_Seating(seating, cht.rows, cht.columns);
for (i = 0; i < cht.rows; i++)
delete[] seating[i];
delete[] seating;
system("Pause");
return 0;
//cout << "Enter" << d1 << "rows of "
//<< d2 << "seats" << endl;
}
Seating user_input()
{
Seating cht;
cout << "**Please Do Not Enter More Than Thirty (30) Rows and Twenty (20) Seats**"
<< "\n You Have Been Warned!" << endl;
do {
cout << "Enter the number of rows for the plane.\n>";
cin >> cht.rows;
if (cht.rows > 30)
cout << "Can you not read? Try again..." ;
} while (cht.rows > 30);
do {
cout << "Enter the number of seats for the plane.\n>";
cin >> cht.columns;
for (int i = 0; i < cht.rows; i++)
if (cht.columns > 20)
cout << "Seriously? Try again..." ;
} while (cht.columns > 20);
//cht.columns = columns;
//cht.rows = rows;
return cht;
}
void Initialize_Seating(SeatingChartPtr seating, int rows, int columns)
{
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
seating[i][j] = toupper('A') + j;
}
/// LOOK HERE !!!
void Display_Seating(SeatingChartPtr seating, int rows, int columns)
{
for (int i = 0; i < rows; i++)
{
/// this IF statement does NOT work
if (rows > 10 ) // it was 5 earller for testing purposes
cout << i + 1 << " ";
else
cout << i + 1 << " ";
for (int j = 0; j < columns; j++)
cout << seating[i][j];
cout << endl;
}
}
//
|