标签:style blog color io for div 代码 sp log
#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; }
标签:style blog color io for div 代码 sp log
原文地址:http://www.cnblogs.com/LLGemini/p/3956383.html