欧美一区2区三区4区公司二百,国产精品婷婷午夜在线观看,自拍偷拍亚洲精品,国产美女诱惑一区二区

c語言之fcfs

#include <malloc.h>
#include <stdio.h>
?
typedef struct?
{
? ? char name[10];//進(jìn)程名
? ? int id;//進(jìn)程id
? ? int atime;//到達(dá)時間
? ? int stime;//開始時間
? ? int runtime;//運(yùn)行時間
? ? int ftime;//完成時間
? ? float total;//周轉(zhuǎn)時間
? ? float weight;//帶權(quán)周轉(zhuǎn)時間
}PCB;
?
typedef struct _Node
{
? ? struct _Node* next;
? ? PCB pcb;
}node;
?
struct node* creat()
{
? ? node* head = malloc(sizeof(node));
? ? head->next = NULL;
? ? node* move = head;
?
? ? printf("請輸入進(jìn)程數(shù)量:\n");
? ? int count;
? ? scanf("%d", &count);
? ? for (int i = 0; i < count; i++)
? ? {
? ? ? ? node* fresh = malloc(sizeof(node));
? ? ? ? fresh->next = NULL;
? ? ? ? move->next = fresh;
?
? ? ? ? printf("請輸入第%d個進(jìn)程的id、到達(dá)時間、運(yùn)行時間:\n", i + 1);
? ? ? ? scanf("%d%s%d%d", &fresh->pcb.id, fresh->pcb.name, &fresh->pcb.atime, &fresh->pcb.runtime);
?
? ? ? ? move = fresh;
? ? }
? ? return head;
}
?
void fcfs(node* head) {
? ? for (node* turn = head->next; turn->next != NULL; turn = turn->next)
? ? {
? ? ? ? for (node* move = head->next; move->next != NULL; move = move->next)
? ? ? ? {
? ? ? ? ? ? if (move->pcb.atime > move->next->pcb.atime)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? PCB temp = move->pcb;
? ? ? ? ? ? ? ? move->pcb = move->next->pcb;
? ? ? ? ? ? ? ? move->next->pcb = temp;
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
?
void running(node* head) {
? ? node* move = head->next;//創(chuàng)建move指針控制循環(huán)次數(shù)
? ? while (move != NULL) {
? ? ? ? printf("%s程序正在運(yùn)行.....\n", move->pcb.name);
? ? ? ? move = move->next;
? ? }
}
?
void s_f_t_w_time(node* head) {
? ? node* move = head->next->next;//創(chuàng)建move指針控制循環(huán)次數(shù)
? ? node* first = head->next;//將首結(jié)點(diǎn)的地址數(shù)據(jù)傳入first指針中
? ? first->pcb.total = first->pcb.runtime;
? ? first->pcb.stime = first->pcb.atime;
? ? first->pcb.ftime = first->pcb.stime + first->pcb.runtime;
? ? first->pcb.weight = first->pcb.total / first->pcb.runtime;
? ? printf("%d %4s %7d %11d %10d %10d %16f %10f\n", first->pcb.id, first->pcb.name, first->pcb.atime, first->pcb.runtime, first->pcb.stime, first->pcb.ftime, first->pcb.total, first->pcb.weight);
? ? while (move != NULL) {
? ? ? ? if (first->next->pcb.atime <= first->pcb.ftime) {
? ? ? ? ? ? first->next->pcb.stime = first->pcb.ftime;
? ? ? ? ? ? first->next->pcb.ftime = first->next->pcb.stime + first->next->pcb.runtime;
? ? ? ? ? ? first->next->pcb.total = first->next->pcb.stime + first->next->pcb.runtime - first->next->pcb.atime;
? ? ? ? ? ? first->next->pcb.weight = first->next->pcb.total / first->next->pcb.runtime;
? ? ? ? }
? ? ? ? else {
? ? ? ? ? ? first->next->pcb.stime = first->next->pcb.atime;
? ? ? ? ? ? first->next->pcb.ftime = first->next->pcb.stime + first->next->pcb.runtime;
? ? ? ? ? ? first->next->pcb.total = first->next->pcb.stime + first->next->pcb.runtime - first->next->pcb.atime;
? ? ? ? ? ? first->next->pcb.weight = first->next->pcb.total / first->next->pcb.runtime;
? ? ? ? }
? ? ? ? printf("%d %4s %7d %11d %10d %10d %16f %10f\n", first->next->pcb.id, first->next->pcb.name, first->next->pcb.atime, first->next->pcb.runtime, first->next->pcb.stime, first->next->pcb.ftime, first->next->pcb.total, first->next->pcb.weight);
? ? ? ? first = first->next;
? ? ? ? move = move->next;
? ? }
}
?
int main(void) {
? ? node* p;
? ? p = creat();
? ? fcfs(p);
? ? printf("\n");
? ? running(p);
? ? printf("\n");
? ? printf(" id ? ?進(jìn)程名 ? 到達(dá)時間 ? 運(yùn)行時間 ? 開始時間 ? 結(jié)束時間 ? 周轉(zhuǎn)時間 ? 帶權(quán)周轉(zhuǎn)時間\n");
? ? s_f_t_w_time(p);
? ? return 0;
}

c語言之fcfs

?

文章鏈接: http://www.qzkangyuan.com/27155.html

文章標(biāo)題:c語言之fcfs

文章版權(quán):夢飛科技所發(fā)布的內(nèi)容,部分為原創(chuàng)文章,轉(zhuǎn)載請注明來源,網(wǎng)絡(luò)轉(zhuǎn)載文章如有侵權(quán)請聯(lián)系我們!

聲明:本站所有文章,如無特殊說明或標(biāo)注,均為本站原創(chuàng)發(fā)布。任何個人或組織,在未征得本站同意時,禁止復(fù)制、盜用、采集、發(fā)布本站內(nèi)容到任何網(wǎng)站、書籍等各類媒體平臺。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。

給TA打賞
共{{data.count}}人
人已打賞
建站教程

數(shù)據(jù)結(jié)構(gòu)之棧(四)

2023-12-22 10:09:01

建站教程投稿分享

c語言之SJF

2024-1-29 13:16:21

0 條回復(fù) A文章作者 M管理員
    暫無討論,說說你的看法吧
?
個人中心
購物車
優(yōu)惠劵
今日簽到
有新私信 私信列表
搜索

夢飛科技 - 最新云主機(jī)促銷服務(wù)器租用優(yōu)惠

主站蜘蛛池模板: 富源县| 崇义县| 哈尔滨市| 淮安市| 临颍县| 玉树县| 微博| 抚宁县| 赞皇县| 威远县| 龙口市| 湖北省| 望奎县| 祁连县| 改则县| 巢湖市| 平泉县| 方城县| 平远县| 合阳县| 东丰县| 神农架林区| 鄂尔多斯市| 玛多县| 黔西| 黄骅市| 鸡泽县| 沿河| 庄河市| 泽库县| 沅江市| 舒兰市| 凭祥市| 曲松县| 扶风县| 邹平县| 启东市| 凯里市| 开阳县| 东乌珠穆沁旗| 英德市|