#include
#include
int total_time = 20;
int time_slice = 3;
typedef struct process{
char pname[10];//进程名
int WaitTime;//数据
int priority;//数字越大优先级越高
struct process *next;
}PROCESS;
int in_queue(PROCESS *head,PROCESS *p);
void run();
PROCESS *init()
{
int i = 0;
char a;
PROCESS *head_new;
head_new = (struct process*)malloc(sizeof(struct process));
if(!head_new) exit(1);
head_new = NULL;
do
{
struct process *s;
printf("请输入各进程\n");
s = (struct process*)malloc(sizeof(struct process));
if(!s) exit(1);
printf("输入进程名,数据,优先级\n");
scanf("%s",&(s->pname));
scanf("%d",&(s->WaitTime));
scanf("%d",&(s->priority));
s->next = NULL;
in_queue(head_new,s);
i++;
}while(i<3);
return head_new;
}
int in_queue(PROCESS *head,PROCESS *p) //入队函数
{
if(head == NULL)
{
head = p;
p->next = NULL;
}
else
{
p->next = head;
head = p;
}
return 0;
}
void run()
{
PROCESS *p,*q;
p = init();
q = p;
while(p->next!=NULL)
{
if(p->priority>=q->priority)
{
q=p;
p=p->next;
}
else
{
p=p->next;
}
}
printf("输出:%c",q->pname);
}
int main()
{
run();
return 0;
}