@vlad from moscow
Yes it is.
@virginiababy
A regular average is defined as the sum of the numbers divided by the number of numbers. So, in your first entry for the array, {1, 100, 100, 100, 100}, the average would be, (100 + 100 + 100 + 100) / 4, which would equate to 100.
For a weighted average, you take the sum of each score multiplied by its weight. So, again using your first example, the weights as given are 20%, 30%, 30%, and 20% for each score. WA = .2*100 + .3*100 + .3*100 + .2*100.
In the code it could be
array1[1][5] = (array[1][1] + array[1][2] + array[1][3] + array[1][4]) / 4
for the regular average
And
array1[1][6] = array[1][1] * .2 + array[1][2] * .3 + array[1][2] * .3 + array[1][4] * .2
for the weighted, both of these could be put into a for loop
for (int i = 0; i < 60; i++) {replace first 1 above, with i here}
As for printing out the array, you are on the write track with your printarray funtion; you would not need to call it as
cout << printarray
, just printarray(array1) would work.
If you replace the
cout << a
with an extra for loop
1 2 3 4 5 6 7 8
|
for(int c=0; c < 60; c++)
{
for (int r = 0; r < 7; r++)
{
cout << a[c][r] << "\t"; // "\t" adds a tab between each value on the line
}
cout << "\n";
}
| |
I am not very good at explaining myself sometimes, so if you have any questions about the above, just let me know.