Tag: 链表式

C:如何释放链表中的节点?

如何释放在另一个函数中分配的节点? struct node { int data; struct node* next; }; struct node* buildList() { struct node* head = NULL; struct node* second = NULL; struct node* third = NULL; head = malloc(sizeof(struct node)); second = malloc(sizeof(struct node)); third = malloc(sizeof(struct node)); head->data = 1; head->next = second; second->data = 2; second->next = third; third->data = […]

可以扩展二次方的C程序

我想有一个C程序,允许我输入(x + 1)(x + 3)和其他类似的东西,包括x ^ 2。 到目前为止,我有一个使用链表的非常复杂的系统,但我认为应该有一个更简单的解决方案。 输入的输出,(x + 1)(x + 3)将打印出x ^ 2 + 4x + 3。 到目前为止,我传递的是一个带有int,char和int的struct _term,用于系数,数字和幂。 所以2x ^ 4将被保存为| 2 |’x’| 3 |。 我还要提到我只有16岁,还在高中。