题目4完成
This commit is contained in:
parent
86c083dc75
commit
c593f3b0e9
24
操作系统/题目4.py
Normal file
24
操作系统/题目4.py
Normal 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__":
|
||||||
|
计算资源需求()
|
Loading…
x
Reference in New Issue
Block a user