首页 > 其他 > 详细

111(保存代码用。。。)

时间:2014-09-04 18:23:49      阅读:288      评论:0      收藏:0      [点我收藏+]
#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(保存代码用。。。)

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!