permutation of a 2D integer array.

I need to get find the maximum possible sum of a 2D array, but can only use one number per row/column (similar to the Hungarian Method). I've been working on the code for quite some time, but I haven't gotten far. I'm fairly new to programming, so the explanations online are far above my knowledge of the C language.

I don't really have much, but here it is:

Code:

int permute(int mmin[10][10], int size){

int q, total=0, sum=0;

for(q=size;q>=0;q--){

mmin=swap(mmin, size, q);

sum=mmin[q][q];

sum+=permute(mmin, q-1);

mmin=swap(mmin, q, size);

printf("\n");

}

return sum;

}

int swap(int mmin[10][10], int j, int k){

int i, temp;

for(i=0;i<=k;i++){

printf("swapping [%d][%d]=%d with [%d][%d]=%d\n", i, j, mmin[i][j], i, k, mmin[i][k]);

temp=mmin[i][j];

mmin[i][j]=mmin[i][k];

mmin[i][k]=temp;

}

return mmin;

}

I know, it's a mess. The program adds the diagonal numbers together ([0][0]+[1][1]+[2][2]+...) but the swap is giving me trouble. I only learned how to print permutations of a word, not of sums of 2D arrays. any help?

Thanks in advance!

I also know that i need an if statement to stop all of the swaps, but I'm not sure where yet...