禾安


私信TA

用户名:ly0708

访问量:561

签 名:

荣耀的背后刻着一道孤独

等  级
排  名 5509
经  验 1473
参赛次数 2
文章发表 3
年  龄 0
在职情况 学生
学  校 安徽农业大学
专  业 计算机科学与技术

  自我简介:

qq 2221940641

TA的其他文章

解题思路:

注意事项:

参考代码:

#include <stdio.h>

#include <stdlib.h>


typedef struct stu{

    int num;

    struct stu *next;

}list,*List;


int main(){

    int n;

    scanf("%d",&n);

    List head,p,q;

    head=(List)malloc(sizeof(list));

    head->num=1;

    q=head;

    for( int i=2; i<=n; i++){

        p=(List)malloc(sizeof(list));

        p->num=i;

        q->next=p;

        q=p;

    }

    q->next=head;

    int i=1;

    p=head;

    while( n!=1 ){

        p=p->next;

        i++;

        if( i==2 ){

            i=1;

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

            p=p->next;

        }

        n--;

    }

    printf("%d",p->num);

    return 0;

}


 

0.0分

0 人评分

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

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区