文章

9

粉丝

0

获赞

55

访问

1.4k

头像
击鼓传花 题解:纯C语言版,数据结构循环单链表来模拟
P1018 贵州大学机试题
发布于2026年3月12日 22:32
阅读数 187

#include<stdio.h>
struct child{
    int val;
    struct child *next;
};
int main()
{
    int N;
    scanf("%d",&N);
    struct child *head=(struct child*)malloc(sizeof(struct child));
    struct child *q;
    head->next=NULL;
    q=head;
    for(int i=1;i<=N;i++)
    {
        struct child *fp=(struct child*)malloc(sizeof(struct child));
        fp->val=i;
        fp->next=NULL;
        q->next=fp;
        q=fp;
    }
    q->next=head->next;
    struct child *p;
    p=head->next;
    int count=0;
    while(N>1)
   &nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发