#include <iostream> #include <cstdio> #include <assert.h> typedef struct student { int score; struct student *next; }linklist; linklist *creat (int n) { linklist *head ,*node ,*end; head = (linklist*) malloc(sizeof (linklist)); end = head ; printf("请输入第0个节点的分数\n"); scanf("%d",&(head->score)); for (int i = 1; i < n; ++i) { node = (linklist *) malloc(sizeof(linklist)); printf("请输入第%d个节点的分数\n",i); scanf("%d",&(node->score)); end->next = node; end =node; } end->next=NULL; return head; } void change(linklist *list , int n) { assert(n>=0); int i = 0; linklist *t = list; while ( i<n && t->next!=NULL) { i++; t = t->next; } if (i==n) { printf("please put the numbers you
C++单向链表的反转
最新推荐文章于 2023-04-19 22:53:17 发布
![](https://img-home.csdnimg.cn/images/20240709112858.png)