#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <malloc.h>
#define OK 1
#define false 0
#define NULL 0
#define overflow 0
#define LIST_MAX_LENGTH 7
#define n LIST_MAX_LENGTH
typedef int Elemtype;
typedef struct LNode{
int num;
int pass;
struct LNode *next;
}LNode, *LinkList;
LinkList CreateList_L()
{
LinkList L;
LinkList p;
int i,m;
L = (LinkList)malloc(sizeof(LNode));
p = L;
for( i=1;i<=n;i++)
{
printf("please input the %dth password:",i);
scanf("%d",&m );
p->next = (LinkList)malloc(sizeof(LNode));
p = p->next;
p->num =i;
p->pass = m;
}
p->next = L->next;
return (L);
}
void main()
{
LinkList people;
LinkList position,pre;
int i,m,count;
clrscr();
people=CreateList_L();
position=people;
pre=people;
printf("please input the initlize password:");
scanf("%d",&m);
for (i=1;i<n;i++)
{
count=0;
do
{
pre=position;
position= position->next;
count++;
}while (count!=m);
printf("%d",position->num);
printf("--");
m=position->pass;
pre->next=position->next;
free(position);
position= pre;
}
printf("%d",position->num);
free(position);
}