mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-24 02:21:30 +08:00
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:
@@ -12,13 +12,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* 链表节点结构体 */
|
||||
struct ListNode {
|
||||
typedef struct ListNode {
|
||||
int val; // 节点值
|
||||
struct ListNode *next; // 指向下一节点的引用
|
||||
};
|
||||
|
||||
// typedef 作用是为一种数据类型定义一个新名字
|
||||
typedef struct ListNode ListNode;
|
||||
} ListNode;
|
||||
|
||||
/* 构造函数,初始化一个新节点 */
|
||||
ListNode *newListNode(int val) {
|
||||
@@ -56,4 +53,4 @@ ListNode *getListNode(ListNode *head, int val) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // LIST_NODE_H
|
||||
#endif // LIST_NODE_H
|
||||
|
||||
@@ -72,12 +72,10 @@ static void printLinkedList(ListNode *node) {
|
||||
printf("%d\n", node->val);
|
||||
}
|
||||
|
||||
struct Trunk {
|
||||
typedef struct Trunk {
|
||||
struct Trunk *prev;
|
||||
char *str;
|
||||
};
|
||||
|
||||
typedef struct Trunk Trunk;
|
||||
} Trunk;
|
||||
|
||||
Trunk *newTrunk(Trunk *prev, char *str) {
|
||||
Trunk *trunk = (Trunk *)malloc(sizeof(Trunk));
|
||||
|
||||
@@ -16,14 +16,12 @@ extern "C" {
|
||||
#define MAX_NODE_SIZE 5000
|
||||
|
||||
/* 二叉树节点结构体 */
|
||||
struct TreeNode {
|
||||
typedef struct TreeNode {
|
||||
int val; // 节点值
|
||||
int height; // 节点高度
|
||||
struct TreeNode *left; // 左子节点指针
|
||||
struct TreeNode *right; // 右子节点指针
|
||||
};
|
||||
|
||||
typedef struct TreeNode TreeNode;
|
||||
} TreeNode;
|
||||
|
||||
TreeNode *newTreeNode(int val) {
|
||||
TreeNode *node;
|
||||
|
||||
Reference in New Issue
Block a user