首页 > 代码库 > 111(保存代码用。。。)
111(保存代码用。。。)
#include <stdio.h>#include <malloc.h>const int maxn = 1000;int Num_of_Player;int m_val;typedef struct{ int num, password; struct LNode *next;}*players, lnode;void init_data(players *p, int n){ p = (lnode)malloc(sizeof(lnode)); scanf("%d", &p->password); p->num = 1; p->next = p; lnode *u, *v; u = p; for(int i = 2; i <= n; i++) { v = (lnode)malloc(sizeof(lnode)); scanf("%d", &v->password); v->num = i; u->next = v; u = v; } if(n > 1) u->next = p;}void solve(lnode *u){ lnode *v; v = u; int cnt = 1; while(v->next != u) { v = v->next; v->next = v->next->next; free(u); }}int main(){ players p; printf("please input the value of m: "); scanf("%d", &m_val); printf("please input the number of players: "); scanf("%d", &Num_of_Player); init_data(p, Num_of_People); solve(); return 0;}
111(保存代码用。。。)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。