【问题描述】
利用Python编写一个程序,根据存入的书本量和借出的书本量,来计算图书馆的最终书本量。
设存入的书本量为A,借出的书本量为B,图书馆的最终书本量为C。
假设为程序提供的输入为:
A 500
A 400
B 300
A 200
B 50
那么,程序输出的C值为750。
【算法代码】
s=0
while 1:
x=input()
t=x.split(" ")
if t[0]=="A":
s=s+int(t[1])
elif t[0]=="B":
s=s-int(t[1])
elif t[0]=="C":
print(s)
break