This repository was archived by the owner on Sep 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +13
-13
lines changed Expand file tree Collapse file tree 4 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 1
- // 这个代码是可以编辑并且能够运行的
1
+ // 这个代码是可以编辑并且能够运行的
2
2
fn main ( ) {
3
- // 一个简易计算器
4
- // `+` 或 `-` 意味着加减1
5
- // `*` 或 `/` 意味着乘除2
3
+ // 一个简易计算器
4
+ // `+` 或 `-` 意味着加减1
5
+ // `*` 或 `/` 意味着乘除2
6
6
7
7
let program = "+ + * - /" ;
8
8
let mut accumulator = 0 ;
@@ -13,10 +13,10 @@ fn main() {
13
13
'-' => accumulator -= 1 ,
14
14
'*' => accumulator *= 2 ,
15
15
'/' => accumulator /= 2 ,
16
- _ => { /* 忽略其他 */ }
16
+ _ => { /* 忽略其他 */ }
17
17
}
18
18
}
19
19
20
- println ! ( "程序 \" {}\" 的结果是 {}" ,
20
+ println ! ( "程序 \" {}\" 的结果是 {}" ,
21
21
program, accumulator) ;
22
22
}
Original file line number Diff line number Diff line change 1
1
< pre class ='rust '>
2
2
< span class ='kw '> fn</ span > main() {
3
- < span class ='comment '> // 一个简易计算器
4
- // `+` 或 `-` 意味着加减1
5
- // `*` 或 `/` 意味着乘除2</ span >
3
+ < span class ='comment '> // 一个简易计算器
4
+ // `+` 或 `-` 意味着加减1
5
+ // `*` 或 `/` 意味着乘除2</ span >
6
6
7
7
< span class ='kw '> let</ span > program = < span class ='string '> "+ + * - /"</ span > ;
8
8
< span class ='kw '> let</ span > < span class ='kw '> mut</ span > accumulator = < span class ='number '> 0</ span > ;
13
13
< span class ='string '> '-'</ span > => accumulator < span class ='op '> -=</ span > < span class ='number '> 1</ span > ,
14
14
< span class ='string '> '*'</ span > => accumulator < span class ='op '> *=</ span > < span class ='number '> 2</ span > ,
15
15
< span class ='string '> '/'</ span > => accumulator < span class ='op '> /=</ span > < span class ='number '> 2</ span > ,
16
- _ => { < span class ='comment '> /* 忽略其他 */</ span > }
16
+ _ => { < span class ='comment '> /* 忽略其他 */</ span > }
17
17
}
18
18
}
19
19
20
- < span class ='prelude-val '> println!</ span > (< span class ='string '> "程序 \"{}\" 的结果是 {}"</ span > ,
20
+ < span class ='prelude-val '> println!</ span > (< span class ='string '> "程序 \"{}\" 的结果是 {}"</ span > ,
21
21
program, accumulator);
22
22
}
23
23
</ pre >
Original file line number Diff line number Diff line change 1
- ---
1
+ ---
2
2
layout: zh-CN/default
3
3
title: 下载 · Rust程序语言
4
4
---
Original file line number Diff line number Diff line change 1
- ---
1
+ ---
2
2
layout: zh-CN/basic
3
3
title: Rust程序语言
4
4
---
You can’t perform that action at this time.
0 commit comments