急盼答案
老是出错啊,哪位高手能帮忙啊::\程序\约瑟夫\yueyue.cpp(9) : error C2143: syntax error : missing ';' before 'PCH creation point'
执行 cl.exe 时出错.
代码如下:
#ifndef CNODE_H
#define CNODE_H
class cnode{
public:
int lab;
cnode *next;
}
#endif
#include <iostream.h>
#include "cnode.h"
#include <stdlib.h>
int main()
{
int n;
int m = 3;
cnode *p,*q,*clist;
cin>>n;
//setup n cnode
q = new cnode;
clist = q;
for(int i = 1;i <= n;i++)
{
p = new cnode;
p->lab = i;
p->next = NULL;
q->next = p;
q = p;
if (i == n) q->next = clist->next;
}
//output the label
p = clist;
for (int K = 1; K <= n;K++)
{
for(int j = 1;j < m;j++)
p = p->next;//delete q
if(K == n)
{
cout<<q->lab<<endl;
break;
}
cout<< q->lab<< " ";
p->next = q->next;
delete q;
}
return 0;
}