2023-08-29 16:54:08 +08:00

30 lines
525 B
Rust

// 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<i32>){
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);
}