ok i've written the following function :
Code:
int small_array(int subset, int i, double d[i])
{
int j,n, result;
double temp[subset];
result = 0;
for ( n = 0; n < subset; n++)
{
for ( j = 0; j < i; j++)
{
if (d[result] == 0 || d[result] == temp[0] || d[result] == temp[1]
|| d[result] == temp[2] || d[result] == temp[4]
|| d[result] == temp[5] || d[result] == temp[6]
|| d[result] == temp[7] || d[result] == temp[8]){result = result+1;}
else if (d[result] < d[j]){result = result;}
else if (d[result] > d[j]){result = j;}
else if (d[result] == d[j]){result = result;}
}
temp[n] = d[result];
printf("%d\n", result);
}
printf("\n");
return result;
}
which it takes an array and prints (for the time) the positions in the array that contain the "x"(subset) smallest values (except 0) (the first tests look like it's working) i've pre-set the subset int to 9, but as it is obvious i want to work with different subset values..is there a way to do such a condition...i've tried to put a "for" for the first if...but then the problem is that because if is inside a different loop ..it sees "else" as an error and doesn't compile.
I use a C99 compilere as i found out recently...If there is a way around I would like to know...thanx in advance