Question: Readdat Program ReadData manipulates a two-dimensional table. #include #include #include using namespace std; const int ROW_MAX = 8; const int COL_MAX = 10; typedef int

Readdat

Program ReadData manipulates a two-dimensional table.

#include #include #include using namespace std;

const int ROW_MAX = 8; const int COL_MAX = 10;

typedef int ItemType; typedef ItemType Table[ROW_MAX][COL_MAX];

int main () { Table table; int rowsUsed; int colsUsed; ifstream dataIn; ofstream dataOut; int col; int row;

dataIn.open("debug.dat"); dataOut.open("debug.out"); dataIn >> colsUsed >> rowsUsed;

// Input table values. for (col = 0; col > table[row][col];

// Output table values. for (row = 0; row

return 0; }

Readdat Program ReadData manipulates a two-dimensional table. #include #include #include using namespaceC++

#include #include using namespace std; const int ROW_MAX = 8; const int COL_MAX = 10; typedef int ItemType; typedef ItemType ChartType[ROW_MAX][COL_MAX]; void GetChart(ifstream&, ChartType, int&, int&); // Reads values and stores them in the chart. int findLargest(ChartType, int, int); // to find the Largest value void PrintChart(ofstream&, const ChartType, int, int); // Writes values in the chart to a file. int main () { ChartType chart; int rowsUsed; int colsUsed; ifstream dataIn; ofstream dataOut; dataIn.open("chart2.dat"); dataOut.open("chart2.out"); GetChart(dataIn, chart, rowsUsed, colsUsed); PrintChart(dataOut, chart, rowsUsed, colsUsed); cout > rowsUsed >> colsUsed; for (int row = 0; row > item; chart[row][col] = item; } } //**************************************************** void PrintChart(ofstream& data, const ChartType chart,int rowsUsed, int colsUsed) // Pre: The chart contains valid data. // Post: Values in the chart have been sent to a file by row, // one row per line. { //to print chart by row for (int row=0; row

std; const int ROW_MAX = 8; const int COL_MAX = 10; typedef

This lesson uses program charta. Progran chart2 manipulates atwo-dimonsional array variable #include using nanespace std: conet int ROW HAX-: conet int CoL.HAX10 typedet int ItenType: typeder ItenType chartType [ROW MAX] [coL MAX): void Cetchart(itstreamA, charttype, ints, inta) I Reade valuea and atorea thom in the ehart void PrintChart (ofetreams, const chartType, int, int) Writes values in the chart to a file nt nainO chartType chart int rowUsed: int coleused retrean dataIn: ofstrean dataout: dataIn.open(chart2.dat"): dataout.openchart2.out") Getchart (dataln, chart, rowaUsed, colaused) : Printchart (dataout, chart, rowsUsed, colsused): return 0: vold Cetchart (fetreans data, chartType chart int& rovaUsed, int& colaused) Pre: rovaUsed and eolaUsed are on the firet 1ine of rile data; value's aro ono ro por 11ne beginning vith the second 1ine Post: Values have been read and stored in the chart Arrays I I temtype item data > roaised> claused tor (int row-0; row using nanespace std: conet int ROW HAX-: conet int CoL.HAX10 typedet int ItenType: typeder ItenType chartType [ROW MAX] [coL MAX): void Cetchart(itstreamA, charttype, ints, inta) I Reade valuea and atorea thom in the ehart void PrintChart (ofetreams, const chartType, int, int) Writes values in the chart to a file nt nainO chartType chart int rowUsed: int coleused retrean dataIn: ofstrean dataout: dataIn.open(chart2.dat"): dataout.openchart2.out") Getchart (dataln, chart, rowaUsed, colaused) : Printchart (dataout, chart, rowsUsed, colsused): return 0: vold Cetchart (fetreans data, chartType chart int& rovaUsed, int& colaused) Pre: rovaUsed and eolaUsed are on the firet 1ine of rile data; value's aro ono ro por 11ne beginning vith the second 1ine Post: Values have been read and stored in the chart Arrays I I temtype item data > roaised> claused tor (int row-0; row

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!