1) create a data file of the following structure (each represents the test scores of a class):
the first two numbers are the number of students and the number of tests (integers), respectively.
Then each row represents the test scores of a student. Each student's scores is in different row (it
does not really matter if they are in different row or not, in fact.)
3 6
3.9 4.5 2.1 1.0 2.4 4.3
3.1 4.2 5.1 6.2 1.0 2.7
1.2 2.3 3.1 4.2 5.2 6.4
2) create a program that asks for an input file that has the structure
described in 1).
a)Read the data onto a multidimensional dynamic array of
floats (by means of pointer and new). And print:
b) the average (mean) test score for each student (you could label the student by 1, 2, 3, etc.)
c) Then delete the pointer arrays by using delete function properly.
This is what I have already
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stdio.h>
#include <string>
using namespace std;
float mean (float *FloatArray, float m);
typedef float* IntArrayPtr;
int main(){
int row, col;
ifstream in_stream1;
string file1;
cout << "Enter file name\n";
cin >> file1;
in_stream1.open(file1.c_str());
if(in_stream1.fail()){
//loop if file1 fails to open
cout << "Input file opening failed.\n";
exit(1);
}
in_stream1 >> row >> col;
IntArrayPtr *m= new IntArrayPtr [row];
int i, j;
for (i=0; i<row; i++)
m[i]=new float[col];
//m is now a row and column array.
for (int i=0; i< row; i++)
for(j=0; j< col; j++)
cout << m <<" ";
cin >> m[i][j];
//delete [] m[i];
//delete [] m;
return 0;
Just being honest: You have not clearly defined your SPECIFIC problem, nor have you put your code in [code] tags (ends in [/*code] (remove the *)) so don't expect much help. I doubt anyone frequents here with the intention of completing someone elses homework for them.