Simplify struct declarations of C.

Use PascalCase for all structs in C.
SImplify n_queens.c
Format C code for chapter of graph.
This commit is contained in:
krahets
2023-10-18 02:16:26 +08:00
parent 070d23ee6e
commit 1e49574332
35 changed files with 503 additions and 599 deletions

View File

@@ -28,7 +28,7 @@ int climbingStairsBacktrack(int n) {
int choices[2] = {1, 2}; // 可选择向上爬 1 或 2 阶
int state = 0; // 从第 0 阶开始爬
int *res = (int *)malloc(sizeof(int));
*res = 0; // 使用 res[0] 记录方案数量
*res = 0; // 使用 res[0] 记录方案数量
int len = sizeof(choices) / sizeof(int);
backtrack(choices, state, n, res, len);
int result = *res;

View File

@@ -36,7 +36,7 @@ int climbingStairsDFSMem(int n) {
/* Driver Code */
int main() {
int n = 9;
int res = climbingStairsDFSMem(n);
printf("爬 %d 阶楼梯共有 %d 种方案\n", n, res);

View File

@@ -48,8 +48,10 @@ int main() {
int costSize = sizeof(cost) / sizeof(cost[0]);
printf("输入楼梯的代价列表为 [");
for (int i = 0; i < costSize; i++) {
if (i != costSize - 1) printf("%d, ", cost[i]);
else printf("%d", cost[i]);
if (i != costSize - 1)
printf("%d, ", cost[i]);
else
printf("%d", cost[i]);
}
printf("]\n");