Skip to content

Commit 7e5d6e9

Browse files
committed
update
1 parent 12cc8c5 commit 7e5d6e9

File tree

26 files changed

+200
-483
lines changed

26 files changed

+200
-483
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Hello-Algo-Rust-Zig-C
2-
- [Rust](https://www.rust-lang.org/), [Zig](https://ziglang.org/) and [C](https://www.open-std.org/JTC1/SC22/WG14/) programming language codes for the famous public project [krahets/hello-algo](https://github.com/krahets/hello-algo) <img src="https://img.shields.io/github/stars/krahets/hello-algo?style=social"/> about data structures and algorithms.
1+
# Hello-Algo-Rust-Zig
2+
- [Rust](https://www.rust-lang.org/) and [Zig](https://ziglang.org/) programming language codes for the famous public project [krahets/hello-algo](https://github.com/krahets/hello-algo) <img src="https://img.shields.io/github/stars/krahets/hello-algo?style=social"/> about data structures and algorithms.
33
- Go read this great open access e-book now -> [ hello-algo.com |《Hello, Algorithm》|《 Hello,算法 》](https://www.hello-algo.com/).

c/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

c/build.zig

Lines changed: 0 additions & 41 deletions
This file was deleted.

c/chapter_computational_complexity/time_complexity.c

Lines changed: 0 additions & 176 deletions
This file was deleted.

c/chapter_computational_complexity/worst_best_time_complexity.c

Lines changed: 0 additions & 54 deletions
This file was deleted.

c/include/PrintUtil.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

c/include/include.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

rust/chapter_array_and_linkedlist/array.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
// File: array.rs
2-
// Created Time: 2023-01-15
3-
// Author: xBLACICEx (xBLACKICEx@outlook.com), sjinzh (sjinzh@gmail.com)
1+
/*
2+
* File: array.rs
3+
* Created Time: 2023-01-15
4+
* Author: xBLACICEx (xBLACKICEx@outlook.com), sjinzh (sjinzh@gmail.com)
5+
*/
46

57
include!("../include/include.rs");
68

79
use rand::Rng;
810

9-
// 随机返回一个数组元素
11+
/* 随机返回一个数组元素 */
1012
fn random_access(nums: &[i32]) -> i32 {
1113
// 在区间 [0, nums.len()) 中随机抽取一个数字
1214
let random_index = rand::thread_rng().gen_range(0..nums.len());
@@ -15,7 +17,7 @@ fn random_access(nums: &[i32]) -> i32 {
1517
random_num
1618
}
1719

18-
// 扩展数组长度
20+
/* 扩展数组长度 */
1921
fn extend(nums: Vec<i32>, enlarge: usize) -> Vec<i32> {
2022
// 初始化一个扩展长度后的数组
2123
let mut res: Vec<i32> = vec![0; nums.len() + enlarge];
@@ -27,7 +29,7 @@ fn extend(nums: Vec<i32>, enlarge: usize) -> Vec<i32> {
2729
res
2830
}
2931

30-
// 在数组的索引 index 处插入元素 num
32+
/* 在数组的索引 index 处插入元素 num */
3133
fn insert(nums: &mut Vec<i32>, num: i32, index: usize) {
3234
// 把索引 index 以及之后的所有元素向后移动一位
3335
for i in (index + 1..nums.len()).rev() {
@@ -37,15 +39,15 @@ fn insert(nums: &mut Vec<i32>, num: i32, index: usize) {
3739
nums[index] = num;
3840
}
3941

40-
// 删除索引 index 处元素
42+
/* 删除索引 index 处元素 */
4143
fn remove(nums: &mut Vec<i32>, index: usize) {
4244
// 把索引 index 之后的所有元素向前移动一位
4345
for i in index..nums.len() - 1 {
4446
nums[i] = nums[i + 1];
4547
}
4648
}
4749

48-
// 遍历数组
50+
/* 遍历数组 */
4951
fn traverse(nums: &[i32]) {
5052
let mut _count = 0;
5153
// 通过索引遍历数组
@@ -58,7 +60,7 @@ fn traverse(nums: &[i32]) {
5860
}
5961
}
6062

61-
// 在数组中查找指定元素
63+
/* 在数组中查找指定元素 */
6264
fn find(nums: &[i32], target: i32) -> Option<usize> {
6365
for i in 0..nums.len() {
6466
if nums[i] == target {
@@ -68,7 +70,7 @@ fn find(nums: &[i32], target: i32) -> Option<usize> {
6870
None
6971
}
7072

71-
// Driver Code
73+
/* Driver Code */
7274
fn main() {
7375
let arr = [0; 5];
7476
print!("数组 arr = ");

rust/chapter_array_and_linkedlist/list.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
// File: list.rs
2-
// Created Time: 2023-01-18
3-
// Author: xBLACICEx (xBLACKICEx@outlook.com), sjinzh (sjinzh@gmail.com)
1+
/*
2+
* File: list.rs
3+
* Created Time: 2023-01-18
4+
* Author: xBLACICEx (xBLACKICEx@outlook.com), sjinzh (sjinzh@gmail.com)
5+
*/
46

57
include!("../include/include.rs");
68

7-
// Driver Code
9+
/* Driver Code */
810
fn main() {
911
// 初始化列表
1012
let mut list: Vec<i32> = vec![ 1, 3, 2, 5, 4 ];

0 commit comments

Comments
 (0)