static int getSuccessor ( int arr [ ] , int k , int n ) {
  int p = k - 1 ;
  while ( arr [ p ] == n ) {
    p -- ;
    if ( p < 0 ) {
      break ;
    }
  }
  if ( p < 0 ) {
    return 0 ;
  }
  arr [ p ] = arr [ p ] + 1 ;
  for ( int i = p + 1 ;
  i < k ;
  i ++ ) {
    arr [ i ] = 1 ;
  }
  return 1 ;
}

static int getSuccessor ( int arr [ ] , int k , int n ) { int p = k - 1 ; while ( arr [ p ] == n ) { p -- ; if ( p < 0 ) { break ; } } if ( p < 0 ) { return 0 ; } arr [ p ] = arr [ p ] + 1 ; for ( int i = p + 1 ; i < k ; i ++ ) { arr [ i ] = 1 ; } return 1 ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) body: (block (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (break_statement))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))) (return_statement (decimal_integer_literal))))