Here is a few pointers to help you along, first of, in this assingment you need to create a function which will read all your numbers into your list, look at the
Sudoku thread for something similar.
Then compare your thoughts to this pseudo-code
Code:
#include <iostream>
#include <fstream>
#define SIZE 101
#define FILENAME "C:\\data.dat"
/* when theres an NxN array you call it a matrix */
int number_matrix[SIZE][SIZE];
bool load_matrix(void)
{
std::istream in_file(FILENAME);
if(!in_file || in_file.fail()){
std::cout << "Error opening file: " << FILENAME << std::endl;
return false;
}
for(int i=0; i < SIZE; ++i)
for(int j=0; j < SIZE; ++j)
if(!(in_file >> number_matrix[ i][j])){
std::cout << "Not enough numbers to fill the matrix" << std::endl;
in_file.close();
return false;
}
in_file.close();
return true;
}
Next problem on your aggenda, is to total some predefined row and column in your matrix, considder this pseudo-code
Code:
int total_row(unsigned int row)
{
int res=0;
for(int i=0; i < SIZE; ++i)
res+=number_matrix[row][ i];
return res;
}
int total_column(unsigned int col)
{
int res=0;
for(int i=0; i < SIZE; ++i)
res+=number_matrix[ i][col];
return res;
}
Then find some way to combine those functions, so your program will provide you with the needed result, in order to complete this assignment..
Oh. look I practicaly provided you with the answer.. what's next, should I give you the main() function aswell ?