Hi there guys,
I am trying to write a C++ program which takes in a float from a user, between 0 and 3 and stores it in a matrix. I then need to compare the totals of each row, then state which row is the highest. From this highest row, I then need to find the highest value. I have been playing about with this for a few hours now... This is what I have got working so far...
Any suggestions?Code:#include <iostream.h> #include <iomanip.h> #include <conio.h> #include <stdlib.h> int main (void) { const int ROWS = 8; // 8 columns const int COLUMNS = 8; // 8 rows int row; int col; float table[ ROWS ][ COLUMNS ]; float row_count; float col_count; for ( row = 0; row < ROWS; ++row) { for ( col = 0; col < COLUMNS; ++col ) { cout << endl << "Enter data for row " << (row + 1) << ", column " << (col + 1) << " : "; cin >> table[ row ][ col ]; } } cout << endl << " Original Matrix"; cout << endl; for (row =0; row < ROWS; ++row ) { for (col =0; col < COLUMNS; ++col) { cout << setw(10) << table[ row ][ col ]; } cout << endl; } system("PAUSE"); for ( row=0; row < ROWS; ++row ) { row_count = 0; for ( col =0; col < COLUMNS; ++col) { row_count = row_count + table[ row ][ col ]; } cout << endl << "The sum of row " << (row + 1) << " is " << row_count; } cout << endl; system("PAUSE"); for ( col = 0; col < COLUMNS; ++col ) { col_count = 0; for ( row =0; row < ROWS; ++row) { col_count = col_count + table[ row ][ col ]; } cout << endl << "The sum of the column " << (col + 1) << " is " << col_count; } system("PAUSE"); return ( 0 ); }
HarryMin