I expected this lessons !
Feedback :
when you read in your numbers - be careful what variable you store them to:
&b1, &c1 , &g1 - was the wrong order ,
I SPENT 2 HOURS FINDING THE BUG - BUT it was storing them in wrong order to wrong variables!
&b1, &g1 , &c1 - was right!
-----------------------------------------------------------------
#include <iostream>
#include <stdio.h>
#include <string.h>
#define INT_MAX 2147483647
using namespace std ;
int main(){
int b1,b2,b3 ;
int c1,c2,c3 ;
int g1,g2, g3 ;
int min_move = INT_MAX ;//cool!
int answers[6] ;
while( cin >>b1 >> g1 >>c1 >> b2 >> g2 >> c2 >> b3 >> g3 >> c3 ){
//cout << "processing this line"<<endl ;
//BCG
answers[0] = ( c1 + g1) + (b2 + g2) + (b3 + c3) ;
//BGC
answers[1] = (g1 + c1) + (b2 + c2) + (b3 + g3) ;
//CBG
answers[2] = (b1 + g1) + (g2 + c2) + (b3 + c3) ;
//CGB
answers[3] = (b1 + g1) + (b2 + c2) + (g3 + c3) ;
//GBC
answers[4] = (b1 + c1) + (g2 + c2) + (b3 + g3) ;
//GCB
answers[5] = (b1 + c1) + (b2 + g2) + (g3 + c3) ;
//5 10 5 20 10 5 10 20 10
min_move = INT_MAX ;
for(int i = 0 ; i < 6;i++){
//cout << "******** finding min " << endl ;
if( answers[i] < min_move){
min_move = answers[i] ;
}
}
//cout << "in here , min found, it is " << min_move <<endl ;
for(int i = 0 ; i < 6 ;i++){
// cout <<"inside loop that does printing!" <<endl ;
if(answers[i] == min_move){
if( i == 0 )cout << "BCG " ;
else if(i == 1) cout<< "BGC " ;
else if(i == 2) cout << "CBG " ;
else if(i == 3) cout << "CGB " ;
else if(i == 4 ) cout << "GBC " ;
else if(i == 5) cout << "GCB " ;
cout << min_move <<endl ;
// cout << "break out !" ;
break ;
}
}
}//end while
return 0 ;
}