私信TA

用户名:2472727869

访问量:18118

签 名:

哈哈哈

等  级
排  名 567
经  验 4197
参赛次数 0
文章发表 16
年  龄 24
在职情况 在职
学  校
专  业

  自我简介:

没上进心的客服

#include<stdio.h>

struct node{

int date;

struct node *next;

};

int main()

{

int n,i;

    scanf("%d",&n);

    struct node *headNode=(struct node *)malloc(sizeof(struct node));//初始化 

    headNode->date=1;

    struct node *a=(struct node *)malloc(sizeof(struct node));

    headNode->next=a;

    a->date=2;

    a->next=headNode;

    for(i=3;i<=n;i++){

    struct node *newNode=(struct node *)malloc(sizeof(struct node));

    newNode->date=i;

    a->next=newNode;

    newNode->next=headNode;

    a=newNode;

    }  

    struct node *p=headNode;

    while(1)

    {

    if(p==p->next)

    break;

    p=p->next;

p->next=p->next->next;

p=p->next;  

    }

    printf("%u\n",p->date);

    return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区