You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
658 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// functions4.rs
// 让我能够编译!执行 `rustex hint functions4` 获取提示 :)
// 商店正在进行促销,如果价格是偶数,可以优惠 10 Rustbucks如果是奇数则优惠 3 Rustbucks。
// 译Rustbucks 可能想表达 Rust元 的意思,好比 美元 。
// I AM NOT DONE
/// 翻译: [mg-chao](https://github.com/mg-chao)
fn main() {
let original_price = 51;
println!("Your sale price is {}", sale_price(original_price));// 译:"你需支付 {}"
}
fn sale_price(price: i32) -> {
if is_even(price) {
price - 10
} else {
price - 3
}
}
fn is_even(num: i32) -> bool {
num % 2 == 0
}