【问题描述】输出找零钱的结果
【输入形式】
【输出形式】
【样例输入】152
【样例输出】
100,1
50,1
20,0
10,0
1,2
【样例说明】
【评分标准】
amount = int(input())
# 计算各面额的张数
notes = [100, 50, 20, 10, 1]
for note in notes:
count = amount // note
amount %= note
print(f"{note},{count}")
该文章详细描述了如何使用Python编写一个找零算法,给出输入输出样例,用于计算给定金额需要的各面额纸币数量。
【问题描述】输出找零钱的结果
【输入形式】
【输出形式】
【样例输入】152
【样例输出】
100,1
50,1
20,0
10,0
1,2
【样例说明】
【评分标准】
amount = int(input())
# 计算各面额的张数
notes = [100, 50, 20, 10, 1]
for note in notes:
count = amount // note
amount %= note
print(f"{note},{count}")

被折叠的 条评论
为什么被折叠?