码迷,mamicode.com
首页 > 其他好文 > 详细

111(保存代码用。。。)

时间:2014-09-04 18:23:49      阅读:242      评论:0      收藏:0      [点我收藏+]

标签: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;
}

 

111(保存代码用。。。)

标签:style   blog   color   io   for   div   代码   sp   log   

原文地址:http://www.cnblogs.com/LLGemini/p/3956383.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!