Finding smallest character after ' i - 1' and greater than temp [ i - 1 ]
int min = i ; int j , x = temp [ i - 1 ] ; for ( j = i + 1 ; j < temp . length ( ) ; j ++ ) if ( ( temp [ j ] < temp [ min ] ) and ( temp [ j ] > x ) ) min = j ;