2 u012222415 u012222415 于 2013.09.23 20:17 提问

约瑟夫环代码错误,不知道哪里出了问题

#include
using namespace std;

typedef struct Node
{
int num;
int password;
struct Node *next;
}List;

List *create(int n)
{
List *p, *q, *head;
int i = 1;
head = new List;
p = head;
cout<<"请输入第"< cin>>p->password ;
for(i = 2;i <= n;i++)
{
q = new List;
cout<<"请输入第"< cin>>q->password ;
p->next = q;
p = p->next ;
}
p->next = head;
return head;
}

int output(List *L)
{
int m, i;
List *p = L, *q, *s;
q = p;
cout<<"请输入m的初值"< cin>>m;
cout<<"出列顺序为:"< while(q != NULL)
{
for(i = 1; i {
q = p;
p = p->next ;
}
q->next = p->next;
cout<password < m = p->password;
q = p->next ;
delete(p);
}
return 0;
}

int main()
{
List *L;
int n;
cout<<"请输入实验人数"< cin>>n;
L = create(n);
output(L);
return 0;
}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!