Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let input = [-1, -1, -1, 0, 0, 0, 1, 1, 1];
- let mut neg_one_locations = Vec::new();
- let mut zero_locations = Vec::new();
- let mut pos_one_locations = Vec::new();
- for i in input.iter() {
- match input[i] {
- -1 => neg_one_locations.push(i),
- 0 => zero_locations.push(i),
- 1 => pos_one_locations.push(i),
- }
- }
- println!(
- "Negatives locations: {:?}, Zeros locations: {:?}, Positives locations: {:?}",
- neg_one_locations, zero_locations, pos_one_locations
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement