🌈 style:

This commit is contained in:
lzy
2024-05-26 15:39:14 +08:00
parent 6f28a3384a
commit a57bbdb4c1
156 changed files with 765 additions and 770 deletions

View File

@@ -3,9 +3,9 @@
#include "list.h"
list *list_create()
list* list_create( )
{
list *me;
list* me;
me = malloc(sizeof(*me));
if (NULL == me)
return NULL;
@@ -16,7 +16,7 @@ list *list_create()
}
// 从第一个有效节点作为第0个
int list_insert_at(list *me, int i, datatype *data)
int list_insert_at(list* me, int i, datatype* data)
{
int k = 0;
list *node = me, *newnode;
@@ -50,7 +50,7 @@ int list_insert_at(list *me, int i, datatype *data)
}
// 有序插入
int list_order_insert(list *me, datatype *data)
int list_order_insert(list* me, datatype* data)
{
list *p = me, *q;
@@ -68,7 +68,7 @@ int list_order_insert(list *me, datatype *data)
return 0;
}
int list_delete_at(list *me, int i, datatype *data)
int list_delete_at(list* me, int i, datatype* data)
{
int k = 0;
list *p = me, *q;
@@ -98,7 +98,7 @@ int list_delete_at(list *me, int i, datatype *data)
return -2;
}
int list_delete(list *me, datatype *data)
int list_delete(list* me, datatype* data)
{
list *p = me, *q;
while (p->next && p->next->data != *data)
@@ -117,16 +117,16 @@ int list_delete(list *me, datatype *data)
return 0;
}
int list_isempty(list *me)
int list_isempty(list* me)
{
if (NULL == me->next)
return 0;
return 1;
}
void list_display(list *me)
void list_display(list* me)
{
list *node = me->next;
list* node = me->next;
if (0 == list_isempty(me))
return;
@@ -140,7 +140,7 @@ void list_display(list *me)
return;
}
void list_destroy(list *me)
void list_destroy(list* me)
{
list *node, *next;

View File

@@ -5,22 +5,22 @@ typedef int datatype;
typedef struct node_st
{
datatype data;
struct node_st *next;
}list;
datatype data;
struct node_st* next;
} list;
list *list_create();
list* list_create( );
int list_insert_at(list *me, int i, datatype *data);
int list_order_insert(list *me, datatype *data);
int list_insert_at(list* me, int i, datatype* data);
int list_order_insert(list* me, datatype* data);
int list_delete_at(list *me, int i, datatype *data);
int list_delete(list *me, datatype *data);
int list_delete_at(list* me, int i, datatype* data);
int list_delete(list* me, datatype* data);
int list_isempty(list *me);
int list_isempty(list* me);
void list_display(list *me);
void list_destroy(list *me);
void list_display(list* me);
void list_destroy(list* me);
#endif

View File

@@ -3,12 +3,12 @@
#include "list.h"
int main()
int main( )
{
list *l;
list* l;
datatype arr[] = {12, 9, 23, 2, 34, 6, 45};
l = list_create();
l = list_create( );
if (NULL == l)
exit(1);

View File

@@ -6,7 +6,7 @@
typedef struct node_st
{
int data;
struct node_st *next;
struct node_st* next;
} list;
// try something
@@ -32,7 +32,7 @@ list *jose_create(int a[], int n)
}
#endif
list *jose_create(int n)
list* jose_create(int n)
{
list *me, *newnode, *cur;
int i = 1;
@@ -61,9 +61,9 @@ list *jose_create(int n)
return me;
}
void jose_show(list *me)
void jose_show(list* me)
{
list *list;
list* list;
for (list = me; list->next != me; list = list->next)
{
@@ -74,7 +74,7 @@ void jose_show(list *me)
printf("%d\n", list->data);
}
void jose_kill(list **me, int n)
void jose_kill(list** me, int n)
{
list *cur = *me, *node;
int i = 1;
@@ -101,9 +101,9 @@ void jose_kill(list **me, int n)
printf("\n");
}
int main()
int main( )
{
list *list;
list* list;
list = jose_create(JOSE_NUM);

View File

@@ -3,18 +3,18 @@
#include "nohead.h"
int main()
int main( )
{
int i, ret;
struct node_st *list = NULL;
struct node_st* list = NULL;
struct score_st tmp;
for (i = 0; i < 7; i++)
{
tmp.id = i;
snprintf(tmp.name, NAMESIZE, "stu%d", i);
tmp.math = rand() % 100;
tmp.chinese = rand() % 100;
tmp.math = rand( ) % 100;
tmp.chinese = rand( ) % 100;
// list = list_insert(list, &tmp);
ret = list_insert(&list, &tmp);
@@ -28,7 +28,7 @@ int main()
printf("\n\n");
int id = 13;
struct score_st *ptr;
struct score_st* ptr;
ptr = list_find(&list, id);
if (NULL == ptr)
printf("Can not find!\n");

View File

@@ -21,9 +21,9 @@ struct node_st *list_insert(struct node_st *list, struct score_st *data)
}
#endif
int list_insert(struct node_st **list, struct score_st *data)
int list_insert(struct node_st** list, struct score_st* data)
{
struct node_st *new;
struct node_st* new;
new = malloc(sizeof(*new));
if (NULL == new)
@@ -36,9 +36,9 @@ int list_insert(struct node_st **list, struct score_st *data)
return 0;
}
void list_show(struct node_st *list)
void list_show(struct node_st* list)
{
struct node_st *cur;
struct node_st* cur;
for (cur = list; NULL != cur; cur = cur->next)
{
@@ -51,9 +51,9 @@ void list_show(struct node_st *list)
}
// 删除首位
int list_delete(struct node_st **list)
int list_delete(struct node_st** list)
{
struct node_st *cur;
struct node_st* cur;
if (NULL == *list)
return -1;
@@ -66,9 +66,9 @@ int list_delete(struct node_st **list)
return 0;
}
struct score_st *list_find(struct node_st **list, int id)
struct score_st* list_find(struct node_st** list, int id)
{
struct node_st *cur;
struct node_st* cur;
if (NULL == *list)
return NULL;
@@ -91,9 +91,9 @@ struct score_st *list_find(struct node_st **list, int id)
return NULL;
}
int list_destroy(struct node_st **list)
int list_destroy(struct node_st** list)
{
struct node_st *cur;
struct node_st* cur;
if (NULL == list)
return -1;

View File

@@ -11,16 +11,16 @@ struct score_st
struct node_st
{
struct score_st data;
struct node_st *next;
struct node_st* next;
};
// struct node_st *list_insert(struct node_st *list, struct score_st *data);
int list_insert(struct node_st **list, struct score_st *data);
int list_insert(struct node_st** list, struct score_st* data);
void list_show(struct node_st *list);
void list_show(struct node_st* list);
int list_delete(struct node_st **list);
int list_delete(struct node_st** list);
struct score_st *list_find(struct node_st **list, int id);
struct score_st* list_find(struct node_st** list, int id);
int list_destroy(struct node_st **list);
int list_destroy(struct node_st** list);

View File

@@ -5,10 +5,10 @@ typedef struct node_st
{
int coef;
int exp;
struct node_st *next;
struct node_st* next;
} list;
list *poly_create(int a[][2], int n)
list* poly_create(int a[][2], int n)
{
list *me, *newnode, *cur;
@@ -36,9 +36,9 @@ list *poly_create(int a[][2], int n)
return me;
}
void poly_show(list *me)
void poly_show(list* me)
{
list *cur;
list* cur;
for (cur = me->next; NULL != cur; cur = cur->next)
{
@@ -47,7 +47,7 @@ void poly_show(list *me)
printf("\n");
}
void poly_union(list *p1, list *p2)
void poly_union(list* p1, list* p2)
{
list *p, *q, *r;
@@ -89,7 +89,7 @@ void poly_union(list *p1, list *p2)
r->next = p;
}
int main()
int main( )
{
int a[][2] = {{5, 0}, {2, 1}, {8, 8}, {3, 16}};
int b[][2] = {{6, 1}, {16, 6}, {-8, 8}};