解题思路:
注意事项:
参考代码:
#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语言代码)浏览:1300 |
程序员的表白 (C语言代码)浏览:1328 |
求圆的面积 (C语言代码)浏览:1271 |
哥德巴赫曾猜测 (C语言代码)浏览:2350 |
母牛的故事 (C语言代码)浏览:716 |
字符逆序 (C语言代码)浏览:617 |
陈教主的三角形 (C语言代码)浏览:1143 |
字符串比较 (C语言代码)浏览:685 |
整除问题 (C语言代码)浏览:526 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:810 |