c语言 不知道问题出在哪里

来源:百度知道 编辑:UC知道 时间:2024/06/22 07:20:15
#include "stdio.h"
#include "stdlib.h"
#include "dos.h"
#include "conio.h"
#define READY 1
#define RUN 2
#define BLOCK 3
typedef struct pcb
{
int num;
struct pcb *next;
int watetime; /* */
int cputime;
int state;
}pcb;
int x;
struct pcb *head;
struct pcb *run;
pcb *creatpc(int n) /* xun huan biao*/
{
int i=1;
pcb *head,*p,*q;
head=NULL;
for(i=1;i<=n;i++)
{
p=(pcb *)malloc(sizeof(pcb));
if(i==1)
{
head=p;
q=p;
}
/* q->priority=random(10); */
p->num=i;
p->watetime=random(10); /* */
p->cputime=random(10)+1; /* to day*/
p->state=READY;
q->next=p;
q=p;
q->next=head;
}
x=n;
return head;
}
pcb *firstcome(struct pcb *head)/* */
{ struct pcb *p,*q;
p

函数rand()%10,不是random(10)

还有sleep的头文件问题
http://zhidao.baidu.com/question/83368752.html

程序出错了就看下面的错误提示,提示什么就顺着什么招

除了上面的问题程序还是崩.
你想实现什么功能说一下.然后给你看看

我已经帮你把程序改好了,你看下吧
你函数用的是指针型的,我改了过来,不知道 是否修改了程序的本意,你按照实际情况,再改下吧

#include "stdio.h"
#include "stdlib.h"
#include "dos.h"
#include "conio.h"
#include "math.h"
#define READY 1
#define RUN 2
#define BLOCK 3
typedef struct pcb
{
int num;
struct pcb *next;
int watetime; /* */
int cputime;
int state;
}pcb;
int x;
struct pcb *head;
struct pcb *run;
pcb *creatpc(int n) /* xun huan biao*/
{
int i=1;
pcb *head,*p,*q;
head=NULL;
for(i=1;i<=n;i++)
{
p=(pcb *)malloc(sizeof(pcb));
if(i==1