add solutions for numbers

This commit is contained in:
sunface
2022-03-01 22:24:47 +08:00
parent 258f0ed589
commit 6be05a6686
3 changed files with 151 additions and 23 deletions

View File

@ -67,7 +67,7 @@ fn main() {
}
```
🌟🌟🌟
🌟🌟
```rust,editable
// 修改 `assert!` 让代码工作
@ -90,9 +90,8 @@ fn main() {
let z = 0.01_f64; // f64
}
```
🌟🌟🌟 使用两种方法来让下面代码工作
🌟🌟 使用两种方法来让下面代码工作
> 提示: 1. abs 2. f32
```rust,editable
@ -104,7 +103,6 @@ fn main() {
### 序列Range
🌟🌟 两个目标: 1. 修改 `assert!` 让它工作 2. 让 `println!` 输出: 97 - 122
> Tips: 使用 `as u8` 将字符 `char` 转换成 `u8` 类型
```rust,editable
fn main() {
let mut sum = 0;
@ -114,7 +112,7 @@ fn main() {
assert!(sum == -3);
for c in 'a'..='Z' {
for c in 'a'..='z' {
println!("{}",c);
}
}
@ -136,14 +134,14 @@ fn main() {
🌟
```rust,editable
// 填空
// 填空,并解决错误
fn main() {
// 整数加法
assert!(1u32 + 2 == __);
// 整数减法
assert!(1i32 - 2 == __);
assert!(1u8 - 2 == -1); // 将 u8 修改为另一个类型来让代码工作
assert!(1u8 - 2 == -1);
assert!(3 * 50 == __);
assert!(9.6 / 3.2 == 3.0); // error ! 修改它让代码工作