#include<stdio.h>
#include<malloc.h>
typedef struct people
{
int number;
struct people *next;
}ST;
int main(void)
{
int n = 0;
int i = 0;
scanf("%d", &n);
ST *head, *q, *p, *m;
head = q = (ST*)malloc(sizeof(ST));
head->next = q->next = NULL;
while(i++<n){
p = (ST*)malloc(sizeof(ST));
p->number = i;
p->next = q->next;
q->next = p;
q = p;
}
q->next = head->next;
free(head);
m = q->next;
i = 1;
while(n>1){
if(i%3==0){
n--;
q->next = m->next;
free(m);
}
else{
q = m;
}
m = q->next;
i++;
}
printf("%d", q->number);
return 0;
}
0.0分
0 人评分
大神老白 (C语言代码)浏览:695 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:1072 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)万恶的long long浏览:907 |
淘淘的名单 (C语言代码)浏览:1167 |
WU-蓝桥杯算法提高VIP-勾股数 (C++代码)浏览:1685 |
本人酷爱递归实现很多问题,这里也是浏览:634 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:943 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:593 |
回文数字 (C语言代码)浏览:2539 |
出圈】指针malloc版浏览:377 |