printed out an unsorted array
This commit is contained in:
parent
06461db6de
commit
837804b937
26
src/main.rs
26
src/main.rs
@ -1,13 +1,27 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
|
||||||
//
|
// Array to use
|
||||||
}
|
let test_array : [i32; 6] = [5, 35, 4, 8, 1, 2];
|
||||||
|
|
||||||
//Takes in an array, and returns a sorted array
|
|
||||||
fn selection_sort() {
|
|
||||||
|
|
||||||
|
print!("Here are the values of the array, unsorted: ");
|
||||||
|
for n in test_array {
|
||||||
|
print!("{}, ", n);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn random_array(size : u32) ->
|
//selection_sort : implementation of selection sort
|
||||||
|
//Takes in an array, and returns a sorted array usin
|
||||||
|
//the selection sort algorithm
|
||||||
|
|
||||||
|
// Im going to assume that all functions take in immutable params
|
||||||
|
// Which is nice... but are they references?
|
||||||
|
|
||||||
|
//No. Rust is strictly pass by value on default.
|
||||||
|
// => we must pass a reference to the array
|
||||||
|
fn selection_sort(unsorted_array : &mut [i32]) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user