#include <iostream>
#include <string>
using namespace std;
typedef struct node
{
int number;
int password;
struct node *next;
}SLink;
int GetLength(SLink *sq)
{
int i=1;
SLink *p=sq->next;
while(p!=sq)
{
i++;p=p->next;
}
return i;
}
int DelElem(SLink *sq,int i)
{
int j=1;
SLink *p=sq,*q;
if(i<1 || i>GetLength(sq))
return 0;
else if(i==1)
{
if(GetLength(sq)==1)
{q=sq;free(q);
sq=NULL;}
else
{
while(j<GetLength(sq))
{
p=p->next;j++;
}
q=sq;
p->next=q->next;
sq=q->next;
free(q);
return 1;
}
}
else
{
while(j<i-1)
{
p=p->next;j++;
}
q=p->next;
p->next=q->next;
free(q);
return 1;
}
}
void main()
{
int n;
cout << "n=";
cin >> n;
int m;
cout <<"m=";
cin >> m;
SLink *sq ;
SLink *people = (SLink *)malloc(sizeof(SLink));
people->number=1;
cout << "people->password=" ;
cin >> people->password;
people->next=people;
SLink *lq =people;
for(int i=1;i<n;i++)
{
sq =(SLink *)malloc(sizeof(SLink));
sq->number =i+1;
cout <<"sq->password=";
cin >> sq->password;
lq->next =sq;
sq->next =people;
lq = sq;
}
DelElem(people,1);
for(sq=people;sq->next!=people;sq=sq->next)
{
cout << sq->number;
//cout << sq->next;
}
cout << sq->number;
}
哪位高手能帮帮我为什么是死循环