I've got this nailed down but it's inefficient given it goes back and checks the same thing (a+b+c and a+c+b and the other variants instead of just a+b+c).
Any way to avoid that? My code is as follows:
int array[8]={4,5,6,0,3,2,1,9};
int i = 0, j = 0, k = 0, nmbr = 10;
for(i=0; i<8; ++i){
for(j=0; j<8; ++j){
for(k=0; k<8; ++k){
if((array[i]+array[j]+array[k]) == nmbr)
printf("%d is found with %d + %d + %d\n", nmbr, array[i], array[j], array[k]);
}
}
}
Any help would be appreciated.