diff --git a/exercises/array/array3.rs b/exercises/array/array3.rs new file mode 100644 index 00000000..d1ff24c6 --- /dev/null +++ b/exercises/array/array3.rs @@ -0,0 +1,31 @@ +// array3.rs +// +// Here is the code for how the array learns + +// I AM NOT DONE + + + +struct soultion; + +impl soultion{ + pub fn move_zero(nums:&mut Vec){ + let mut i=0; + for j in 0..nums.len(){ + if nums[j] !=0{ + nums[i] = nums[j]; + i+=1; + } + } + // for loop through + for k in i ..nums.len(){ + nums[k] = 0; + } + } +} + +fn main() { + let mut v = vec![1,23,0,0,0,3,4,5]; + soultion::move_zero( &mut v); + println!("v:{:?}",v); +} \ No newline at end of file