diff --git a/exercises/array/README.md b/exercises/array/README.md new file mode 100644 index 00000000..488aaa33 --- /dev/null +++ b/exercises/array/README.md @@ -0,0 +1,8 @@ +# array + +Arrays are one of the first data types beginner programmers learn. An array is a collection of elements of the same type allocated in a contiguous memory block. + + +## Further information + +- [GitHub Repository](https://github.com/rust-lang/rust-clippy). diff --git a/exercises/array/array1.rs b/exercises/array/array1.rs new file mode 100644 index 00000000..d58a6e45 --- /dev/null +++ b/exercises/array/array1.rs @@ -0,0 +1,42 @@ +// array1.rs +// +// Here is the code for how the array learns + +// I AM NOT DONE + + + +use std :: vec; +fn main() { + // array definition + let number = [1,3,5,7,9,11,1,4]; + let sdf = number[3]; + println!("sdf is {}",sdf); + // How to create an array + let mut v = Vec::new(); + v.push(1); + v.push(23); + v.push(87); + println!("v:{:?}",v); + + let mut v2 = Vec::with_capacity(20); + v2.push(23); + v2.push(12); + v2.push(25); + v2.push(18); + v2.push(21); + v2.push(15); + v2.push(27); + v2.push(10); + v2.push(16); + v2.push(23); + v2.push(12); + // print result + println!("v2:{:?}",v2); + v2.pop(); + println!("v2:{:?}",v2); + // v2.remove(v2[2]); + println!("v3:{:?}",v2); + + +} \ No newline at end of file diff --git a/exercises/array/array2.rs b/exercises/array/array2.rs new file mode 100755 index 00000000..1ebeba59 --- /dev/null +++ b/exercises/array/array2.rs @@ -0,0 +1,34 @@ +// array2.rs +// +// Here is the code for how the array learns + +// I AM NOT DONE + + +struct soultion; + +impl soultion{ + pub fn zero_move(nums: & mut Vec){ + let mut i =0; + let mut j =0; + while j = vec![0,0,3,0,5]; + soultion::zero_move(& mut vec); + println!("{:?}",vec); +}