预览加载中,请您耐心等待几秒...
1/3
2/3
3/3

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

#include<iostream.h> #definemax100 structnode { charname; inttime; inttimed; charstate; node*next; }; node*creat(intn) { node*p,*head,*q; intt,td; charna,s; cout<<"请依次输入‘要求时间’,‘已运行时间’,‘进程名’,‘状态’"<<'\n'; cin>>t>>td>>na>>s; head=newnode; head->name=na; head->time=t; head->timed=td; head->state=s; head->next=NULL; q=head; for(inti=0;i<n-1;i++) { cout<<"请依次输入‘要求时间’,‘已运行时间’,‘进程名’,‘状态’"<<'\n'; cin>>t>>td>>na>>s; p=newnode; p->name=na; p->time=t; p->timed=td; p->state=s; q->next=p; q=p; } q->next=head; returnhead; } voidprint(node*head,intn) { node*p=head; cout<<"进程"<<""<<"时间"<<""<<"已用时间"<<""<<"状态"<<'\n'; for(inti=0;i<n;i++) { cout<<p->name<<'\t'<<p->time<<'\t'<<p->timed<<'\t'<<p->state<<'\n'; p=p->next; } cout<<'\n'; } voidprocess(node*head,intn) { node*p=head; intcount=0; for(inti=0;i<max;i++) { if(count==n) {break;} else { if(p->state=='e') { count++; p=p->next; } else { cout<<"正在运行的进程是:"<<p->name<<'\n'; p->timed++; if(p->time==p->timed) {p->state='e';} print(head,n); p=p->next; count=0; } } } } voidmain() { node*head; intn=5; head=creat(n); print(head,n); cout<<"sortbegin:"<<'\n'; process(head,n); }