解题思路:
注意事项:
参考代码:
#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 人评分
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:660 |
简单的a+b (C语言代码)浏览:808 |
1024题解浏览:806 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:511 |
Hello, world! (C语言代码)浏览:824 |
淘淘的名单 (C语言代码)浏览:1225 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:528 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:663 |
神奇的fans (C语言代码)浏览:979 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:658 |