帮忙看下这代码哪有错,多谢了
帮忙看下这代码哪有错,谢谢了
报错: "declaration syntax error "
# include "stdio.h "
# include "stdlib.h "
typedef struct jcb
{ char name[4];
int length;
int printer;
int tape;
int runtime;
int waittime;
struct jcb * next;
} JCB;
JCB * head;
int tape,printer;
long memory;
shedule()
{ float xk,k;
JCB *p,*q,*t,*s;
do
{ p=head;
q=s=NULL;
k=0;
while(p!=NULL)
{ if (p-> length <=memory&&p-> tape <=tape&&p-> printer <=printer)
{ xk=(float)(p-> waittime)/p-> runtime;
if (q==NULL||xk> k)
{ k=xk;
q=p;
t=s;
}
}
s=p;
p=p-> next;
}
if (q!=NULL)
{ if (t==NULL)
head=head-> next;
else
t-> next=q-> next;
memory=memory-q-> length;
tape=tape-q-> tape;
printer=printer-q-> printer;
printf( "xuan zhong de zuoye ming :%s \n ",q-> name);
}
}while (q!=NULL);
}
main()
{
char name[4];
int i,size,tcount,pcount,wtime,rtime;
JCB *p;
memory=65536;
tape=4;
printer=2;
head=NULL;
printf( " shuru zuoye xiang guan shuju:\n ");
printf( "shu ru zuoye ming ,daxiao,cidaijishu,dayinjishu,dengdai,yunxingt:\n ") ;
scanf( "%s%d%d%d%d%d ",name,&size,&tcount,&pcount,&wtime,&rtime);
while (size!=-1)
{ p=(JCB *)malloc (sizeof(JCB));
strcpy(p-> name,name);
p-> length=size;
p-> printer=pcount;
p-> tape=tcount;
p-> runtime=rtime;
p-> waittime=wtime;
p-> next=head;
head=p;
printf( "shuru zuoye ming ,zuoye daxiao ,cidaiji,dayinji,dengdai,yunxing:\n ");
scanf( "%s%d%d%d%d%d ",name,&size,&tcount,&pcount,&wtime,&rtime);
}
shedule( );
报错: "declaration syntax error "
# include "stdio.h "
# include "stdlib.h "
typedef struct jcb
{ char name[4];
int length;
int printer;
int tape;
int runtime;
int waittime;
struct jcb * next;
} JCB;
JCB * head;
int tape,printer;
long memory;
shedule()
{ float xk,k;
JCB *p,*q,*t,*s;
do
{ p=head;
q=s=NULL;
k=0;
while(p!=NULL)
{ if (p-> length <=memory&&p-> tape <=tape&&p-> printer <=printer)
{ xk=(float)(p-> waittime)/p-> runtime;
if (q==NULL||xk> k)
{ k=xk;
q=p;
t=s;
}
}
s=p;
p=p-> next;
}
if (q!=NULL)
{ if (t==NULL)
head=head-> next;
else
t-> next=q-> next;
memory=memory-q-> length;
tape=tape-q-> tape;
printer=printer-q-> printer;
printf( "xuan zhong de zuoye ming :%s \n ",q-> name);
}
}while (q!=NULL);
}
main()
{
char name[4];
int i,size,tcount,pcount,wtime,rtime;
JCB *p;
memory=65536;
tape=4;
printer=2;
head=NULL;
printf( " shuru zuoye xiang guan shuju:\n ");
printf( "shu ru zuoye ming ,daxiao,cidaijishu,dayinjishu,dengdai,yunxingt:\n ") ;
scanf( "%s%d%d%d%d%d ",name,&size,&tcount,&pcount,&wtime,&rtime);
while (size!=-1)
{ p=(JCB *)malloc (sizeof(JCB));
strcpy(p-> name,name);
p-> length=size;
p-> printer=pcount;
p-> tape=tcount;
p-> runtime=rtime;
p-> waittime=wtime;
p-> next=head;
head=p;
printf( "shuru zuoye ming ,zuoye daxiao ,cidaiji,dayinji,dengdai,yunxing:\n ");
scanf( "%s%d%d%d%d%d ",name,&size,&tcount,&pcount,&wtime,&rtime);
}
shedule( );