| EZX (31) | |||
Calculate a massive A[n][m] elements which are randomized within the interval of [-5, 5], n and m, is inputted by user. Afterwards get all the positive numbers from each line and calculate the median.
Its not doing the if im asking and doesn't calculate it as i need, so frustrating. | |||
|
|
|||
| Peter87 (3672) | |
|
On line 28 you update sum when you should be updating sum1, I think. If you wan the sum of each row you will have to reset sum1 before you start on a new row. The problem description asks for the median and not the sum. | |
|
|
|
| EZX (31) | |
| right but before i can get to median i need sum of all positive numbers no? | |
|
|
|
| AbstractionAnon (412) | |
Line 1 should be: #include <iostream> You need: using namespace std;Line 7 should be: srand (time(NULL));time() requires #include <ctime> http://www.cplusplus.com/reference/cstdlib/srand/ Line 17 should be: a[i][j]=(rand()%11)-5;Line 28 - You have an extraneous close brace. | |
|
|
|
| Peter87 (3672) | |
| Note that median is not necessary the same as the average. I don't think the sum will help you find the median. | |
|
Last edited on
|
|