/*
Name: joseph环
Author:wujilin
Description:课程设计joseph环 就是一个循环链表的运用
Date: 11-07-06 20:11
Copyright:wujilin
*/
#include<stdio.h>
#include<stdlib.h>
typedef struct Node
{
int data;
int password;
struct Node *next;
}Node, *LinkList;
void CreatLinkList(LinkList *L, int n)
{
Node *p, *q;
int i;
(*L) = (LinkList)malloc(sizeof(Node));
if ((*L) == NULL)
{
printf("memory allocation failed, goodbye");
exit(1);
}
p = (*L);
printf("请输入第1个元素的密码:");
scanf("%d",&(p->password));
p->data = 1;
for (i = 2; i <= n; i++)
{
q = (LinkList)malloc(sizeof(Node));
if (q == NULL)
{
printf("memory allocation failed, goodbye");
exit(1);
}
printf("\n请输入第%d个元素的密码:",i);
scanf("%d",&(q->password));
q->data = i;
p->next = q;
p = q;
}
p->next = (*L);}