【发布时间】:2020-03-31 09:40:19
【问题描述】:
所以基本上我正在尝试做一个小程序,让用户输入一个值,然后如果该值等于或大于 x,则折扣类似于 12% 这是一个例子
15% discount, if sales are greater than or equal to 1000
10% discount, if sales are greater than or equal to 500
5% discount, if sales are greater than or equal to 250
0, otherwise.
我知道如何使用 if 语句,但在 switch 中我不知道,输入的值可能有数百万个案例,所以如果可能的话我需要帮助
谢谢
【问题讨论】:
-
为什么要使用开关? switch 的参数应该是什么?
-
你不能在一个开关中做多个大于或等于。听起来像是不适合这项工作的工具。
标签: c++ switch-statement