Question: * ? ? * State of the program * ? ? * : mat.cpp #include #include #include using namespace std; / / the following can

*??* State of the program *??*:
mat.cpp
#include
#include
#include
using namespace std;
// the following can be changed and the rest of the code should work
int const R =3; // number of rows
int const C =4; // number of columns
int const VM =3; // table entry (vector) length
vector T[R][C]; //3 rows and 4 columns table for now
//------------------ Functions --------------------------------
int convert(char x)
{
** do a formula to convert m to 0, n to 1, o to 2 etc.
}
int readTable()
{ int row, col; // row and col numbers
char col_c; // column indicator
ifstream fin ("lines.txt", ios::in);
// Read in the file into T
while (fin >> row)// next line of file
{
fin >> col_c; col = convert(col_c); // convert to a slot number
vector v; // a vector to fill
char c; // one char from the file
//** Fill v with chars from the file (there are VM chars)
//** Put v in T[row][col]
}//end of while
}
// Displays a vector or "---" if the vector is empty
void showVector(vector v)
{ if (v.size()==0)// empty entry
for (int i =1; i <= VM; i++) cout <<"-";
else
// show the content of v separated by blanks (e.g."m n o")
}
// Displays T as a table, separating entries with "|"
void displayTable()
{
//** display T nicely labeled with row numbers (col numbers not needed)
// by calling showVector
}
// Driver
int main()
{
cout << "Reading table from lines.txt..."<< endl;
readTable();
displayTable();
}//the end
---------------------------
lines.txt
0 m m n o
0 n p q r
1 o s t u
1 p v w x
---------------------------
test.1
Reading table from lines.txt ...
0| m n o | p q r |---|---
1|---|---| s t u | v w x
2|---|---|---|---

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!