1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int NUM_ROW =6;
const int NUM_COL =5;
double matrix_members [6][5] ={ {1.267, 0.167, 0.250, 2.670, 1.000},
{3.240, 0.376, 0.375, 3.400, 1.128},
{7.564, 0.668, 0.500, 4.303, 1.270},
{5.041, 1.043, 0.625, 5.313, 1.410},
{4.660, 1.502, 0.750, 7.650, 1.693},
{5.727, 2.044, 0.875, 3.600, 2.257}};
int norm_values,
matrix_mem,
matrix_val,
mem_cel;
double mem_sum,
max_val;
cout << setprecision(1)
<< setiosflags(ios::fixed)
<< setiosflags(ios::showpoint);
// Obtains and prints the matrix members and divides the maximum value cell with each cell in that column.
cout << "Print the normalized matrix value and divides"<< endl;
cout<< "the maximum value cell with the rest of that column"<< endl;
for(norm_values=0; norm_values<NUM_COL; ++norm_values)
{
for(mem_cel=0; mem_cel<NUM_ROW; ++mem_cel)
matrix_mem += matrix_members[norm_values][mem_cel];
matrix_val= matrix_mem + NUM_COL;
cout<< endl <<endl;
mem_sum = 0;
for(mem_cel = 0; mem_cel < NUM_ROW; ++mem_cel)
mem_sum += matrix_members[norm_values][mem_cel];
max_val=(double) mem_sum / NUM_ROW;
cout << endl << endl;
cout << matrix_mem << setw(5) <<""
<< " Value is: " << setw(5) << max_val;
}
cout << endl;
return 0;
}
|