algoritms/stl problem?

J

jimmij

Hello,
I have two algorithms which returns probabilities for something (lets say
probabilities that some animal is a dog, cat or cow). I want to see how
often hierarchy (order) of probabilities is the same in both algorithms.

Piece of code:

/**************************************************/
double prob1[3]; // probabilities for 1st algorithm
double prob2[3]; // second algorithm
//prob[0] - probability that animal is a dog
//prob[1] - ----------- || ------------- cat
//prob[2] - ----------- || ------------- cow

//[...] //calculation of prob1 and prob2

double sortedprob1[3]={prob1[0],prob1[1],prob1[2]};
double sortedprob2[3]={prob2[0],prob2[1],prob2[2]};
sort(sortedprob1, sortedprob1+3);
sort(sortedprob2, sortedprob2+3);
//sortedprob[0] - minimum probability
//sortedprob[2] - maximum probability


//find dog in algorithm1 and then see what is position of dog in
//algoritm2
if(sortedprob1[2] == prob[0]){
for(int i=0; i<3; i++){
if(sortedprob2 == prob2[0])
cout<<"Position of dog in algorithm2 is "<<i<<endl;
}
}
/**************************************************/

QUESTION: How to avoid loop?

I "feel" that it can be simply solved with some algorithms from stl,
however so far I couldn't do it myself.

Suggestions welcome.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top