Passing 2dim array through an median function to the one of 2 other function

I want to use one median function "selectfunction" to choose one of the 2 other functions at random to pass my 2-dim array to the selected function. There is a problem in the median function please help.
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
52
53
54
55
56
57
58

#include <iostream>

#define random(x)(rand()%x) // for random number between numbers of  0 and 1

using namespace std;

void proc1 (int iArray[][2]);
void proc2 (int iArray[][2]);
void selectfunction(int iArray[][2]);

int A[4][2] = {{1, 2} , {3, 4} , { 5, 7} , {8, 1} };


void proc1(int iArray[][2])
{
    int i= 0;
    for (i= 0; i< 4 ; i++)
    {
    cout << iArray[i][0]<< endl;
    }   

}
void proc2(int iArray[][2])
{
    int i= 0;
    for (i= 0; i< 4 ; i++)
    {
       cout << iArray[i][1] << endl;
    }   

} 

void selectfunction(int iArray[][2])
{
int randmix = random(2);
    switch (randmix)
    {
        case 0:
                proc1(int iArray[][2]);
                break;
        case 1:
                proc2(int iArray[][2]);
                break;
    default:
        break;

    } 

}

int main ()
{

    selectfunction(A);
    cin;
    return 0;  
}
Last edited on
1
2
3
4
5
6
        case 0:
                proc1( iArray );
                break;
        case 1:
                proc2( iArray );
                break;


Topic archived. No new replies allowed.