13751652677 发表于 2016-3-12 22:53:10

为什么运行错误

//c语言关键路径
#include
#include
typedef struct arcnode
{
int adjvex; //活动末端
struct arcnode *nextarc;
double info; //活动持续时间
}arcnode;
typedef struct vnode
{
int data; //事件名
arcnode *firstarc;
int du; //入度
}vnode;
typedef struct
{
int vexnum;
int actnum;
vnode *program;
}AOE;
//建立AOE网
void create(AOE T)
{
int i,start,end;
double time;
arcnode *p;
T.program=(vnode *)malloc(T.vexnum*sizeof(vnode));
if(!T.program)
exit(0);
for(i=0;iinfo=time;
p->nextarc=T.program.firstarc;
T.program.firstarc=p;
}
}
//找关键路径
void crtical_activity(AOE T)
{
int *stack=(int*)malloc((T.vexnum+1)*sizeof(int));
double *ve=(double*)malloc(T.vexnum*sizeof(double)); //储存事件最早发生时间
double *vl=(double*)malloc(T.vexnum*sizeof(double)) ; //储存事件最晚发生时间
double *e=(double*)malloc(T.actnum*sizeof(double)); //存储活动最早发生时间
double *l=(double*)malloc(T.actnum*sizeof(double)); //储存活动最晚发生时间
int i,j,k,top=0,bottom=0;
arcnode *p;
double sumtime=0.0;
for(i=0;iadjvex;
T.program.du--;
if(T.program.du==0)
{
stack=k;
}
if(veinfo)
{
ve=ve+p->info;
}
p=p->nextarc;
}
}
sumtime=ve;
for(i=0;i=0;i--)
{
int k=stack;
p=T.program.firstarc;
while(p)
{
j=p->adjvex;
if(vl-p->infoinfo;
}
p=p->nextarc;
}
}
printf("|起点|终点|最早开始时间|最迟开始时间|差|判断|\n");
i=0;
for(j=0;jadjvex;
e[++i]=ve;
l=vl-p->info;
printf("|%4d|%4d|%lf|%lf|%lf|",T.program.data+1,T.program.data+1,e,l,l-e);
if(l==e)
{
printf("关键活动|\n");
}
printf("\n");
p=p->nextarc;
}
}
printf("整个工程所用的最短时间为: %lf个单位时间\n",sumtime);
}
int main()
{
AOE t;
printf("请输入AOE网的事件个数: ");
scanf("%d",&t.vexnum);
printf("请输入AOE网的活动个数: ");
scanf("%d",&t.actnum);
create(t);
crtical_activity(t);
return 0;
}

小甲鱼 发表于 2016-3-12 23:46:05

{:10_266:}1. 代码排版;2. 错误提示什么?

13751652677 发表于 2016-3-14 14:33:45

小甲鱼 发表于 2016-3-12 23:46
1. 代码排版;2. 错误提示什么?

可以输入,但没有得到结果
页: [1]
查看完整版本: 为什么运行错误