Question: A c++ program for one of my classes starts with Initalizing a table of rules vector M[3][5]; I am not familliar with this syntax. Is

A c++ program for one of my classes starts with Initalizing a table of rules

vector M[3][5];

I am not familliar with this syntax. Is it a vector containing arrays? if so how do I place and retrieve values using this table.

If it isnt, what is this syntax referring to and how do I use it?

if it helps here is the template for the program.

vector M[3][5]; // the table of rules

void readrules() { ifstream fin ("rules", ios::in); // ** read in the rules info M, make sure $ is not stored // ** display the table

}

void addtostack(vector V) { cout << "Adding rhs of a rule to the stack" << endl; // ** push V contents to the stack - be careful of the order }

int main() { readrules();

string ss; cout << "Enter a string made of 0's and/or 1's: "; cin >> ss;

// ** push 'S' onto the stack to start cout << "Stack"; // ** display the stack vertically

int i = 0; while (ss[i] != '\0') // for each char of ss { // ** based on the current character, update the stack // ** note that mismatches will cause immediate failure }

// ** check for success for failure based on stack empty or not

}

where the rules are S 0 A 0 $ S 1 A 1 $ A 0 0 $ A 1 1 $

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!