解题思路:
注意事项:
参考代码:
#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语言代码)浏览:1298 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:277 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:1043 |
printf基础练习2 (C语言代码)浏览:305 |
用筛法求之N内的素数。 (C语言代码)浏览:680 |
1048题解(读入回车问题)浏览:566 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:324 |
复数求和 (C语言代码)浏览:930 |
排序算法(选择,插入,冒泡)浏览:777 |
1134题解(求分析)浏览:729 |