Hi,

Im still very new to programming in general and

i wrote some code which doesnt quite work the way i want it

my aim here is to get it to find the minimum in the array and modify the array accordingly, then i want it to take the modified array and find the new minimum and so on

up till now i wrote something that finds the minimum and modifies the array but i dont know how to get it to reuse the modified array to find the new minimum...

heres what i've done:

Code:#include "stdafx.h" #include<stdio.h> int minimum(int array1[3][3]); int _tmain(int argc, _TCHAR* argv[]) { int array1[3][3]={{ 0,113,303}, {113, 0,196}, {303,196, 0}}; int i; int j; int ii; int key=minimum(array1); /*------------------------------------------------------------*/ for(i=0;i<=2;i++){ for (j=0;j<=2;j++){ /* check if min exists check min by col */ if(array1[i][j]==key){ for (ii=0;ii<3;ii++) array1[ii][j]=0; /* because of symmetric matrix when the first minimum is found set its column to zero*/ array1[j][i]=0; /* set the next identical minimum to zero */ break; } } break; } /* print array */ for(i=0;i<=2;i++){ for (j=0;j<=2;j++){ printf("%4d ",array1[i][j]); } printf("\n"); } scanf("%d",&i); return 0; } /*--------------------------------------------------------------------*/ /* find the minimum */ int minimum(int array1[3][3]){ int i; /* i counter */ int j; /* j counter */ int M=999; /* initialise to the highest possible distance */ /* loop through rows of distance */ for (i=0; i < 3; i++){ /*loop through columns of distance */ for (j=0; j < 3; j++){ if (array1[i][j]<M && array1[i][j]!=0){ M=array1[i][j]; } } } return M; }