Compare commits

...

3 Commits

Author SHA1 Message Date
GuanM
c593f3b0e9 题目4完成 2024-11-07 16:53:32 +08:00
GuanM
86c083dc75 大文件移动到lfs 2024-11-01 08:53:19 +08:00
GuanM
b8caca3fc0 更改目录名称 2024-11-01 08:49:12 +08:00
6 changed files with 26 additions and 0 deletions

2
Web/Doc/.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
*.pdf filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text

24
操作系统/题目4.py Normal file
View File

@@ -0,0 +1,24 @@
def 计算资源需求():
可用资源 = list(map(int, input().split()))
进程列表 = []
资源总和 = [0, 0, 0]
for _ in range(5):
行数据 = input().split()
进程 = {
'名称': 行数据[0],
'需求': list(map(int, 行数据[1:4])),
'分配': list(map(int, 行数据[4:7])),
'所需': []
}
进程['所需'] = [c - a for c, a in zip(进程['需求'], 进程['分配'])]
资源总和 = [sum(x) for x in zip(资源总和, 进程['分配'])]
进程列表.append(进程)
资源 = [sum(x) for x in zip(可用资源, 资源总和)]
print(*资源)
for 进程 in 进程列表:
print(进程['名称'], *进程['所需'])
if __name__ == "__main__":
计算资源需求()