首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

求大神帮解决上

2012-10-19 
求大神帮解决下#include stdio#include stdlib.husing namespace stdtypedef int Statustypedef int

求大神帮解决下
#include <stdio>
#include <stdlib.h>
using namespace std;
typedef int Status;
typedef int ElemType;
typedef struct Cnode
{
ElemType data;
struct Cnode *next;
}CNode;
#define OVERFLOW 0
#define ERROR 0
#define ok 1
int n=0,m=0,k=0,i=0;
CNode *p,*q,*clist,*joseph;
Status Create_clist(int n)
{
CNode *p,*q,*clist,*joseph;
clist=(Linklist)malloc(sizeof(CNode));
for(i=n;i>1;i--)
{
if(!(p=((CNode*)malloc(sizeof(CNode)))))
  return OVERFLOW;
p->data=i;
p->next=clist->next;
clist->next=p;
if(i==n) q=p;
}
q->next=clist;
joseph=clist;
return ok;
}
Status Joseph(int m,int n,int k)
{
if(m>n) return ERROR;
p=joseph;
for(i=1;i<m;i++)
{
q=p->next;
return q->data;
printf("%d",q->data);
}


if(p->next==p) p=NULL;
else {
p->next=q->next;
p=p->next;
return q->data;
printf("%d",q->data);
free(q);

}
}
void main( )

printf("请输入n值:");
scanf("%d",&n);
printf("请输入m值:");
scanf("%d",&m);
printf("请输入k值:");
scanf("%d",&k);
Create_clist(n);
Joseph(m,n,k);
}


[解决办法]
#include <stdio>
->
#include <stdio.h> 或者 #include <cstdio>

clist=(Linklist)malloc(sizeof(CNode));
Linklist未定义
应该可以在Cnode定义时加上

typedef struct Cnode
{
 ElemType data;
 struct Cnode *next;
}CNode, *Linklist;
[解决办法]
要解决什么问题呢?没注释。。。

热点排行