/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return string字符串一维数组 * @return int* returnSize 返回数组行数 */ int moveN(int n, char **op, int *returnSize, char *left, char *mid, char *right) { char *str = NULL; if (n == 0) { return 0; } else { moveN(n - 1, op, returnSize, left, right, mid); char *str = (char *)calloc(sizeof(char), 32); if (str == NULL) return -1; sprintf(str, "move from %s to %s", left, right); *(op + *returnSize) = str; (*returnSize)++; moveN(n - 1, op, returnSize, mid, left, right); } return 0; } char** getSolution(int n, int* returnSize ) { char **op = NULL; op = (char **)calloc(sizeof(char*), exp2(n)); if (op == NULL) return NULL; *returnSize = 0; moveN(n, op, returnSize, "left", "mid", "right"); return op; }