#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 人评分
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:537 |
求圆的面积 (C++代码)这里推荐使用宏定义浏览:1928 |
C二级辅导-阶乘数列 (C语言代码)浏览:618 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:567 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:689 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:625 |
买不到的数目 (C++代码)浏览:868 |
【绝对值排序】 (C语言代码)浏览:725 |
上车人数 (C语言代码)浏览:783 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:1047 |