文章
34
粉丝
316
获赞
10
访问
24.3k
//就按照题目说的用链表实现把
#include
#include
struct LNode
{
int data;
struct LNode* next;
};
int main()
{
int n;
scanf("%d", &n);
//先创建循环链表(不带头结点的种)
struct LNode* head = (struct LNode*)malloc(sizeof(struct LNode));
struct LNode tail*=(struct LNode*)malloc(sizeif(struct LNode));
head->next = NULL;
head->data = 1;
//采用头插法
for (int i = n; i >= 2; i--) {
struct LNode* newNode = (struct LNode*)malloc(sizeof(struct LNode));
newNode->data = i;
newNode->next = head->next;
head->next = newNode;
&nb...
登录后发布评论
暂无评论,来抢沙发