Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. fn main() {
  2. let input = [-1, -1, -1, 0, 0, 0, 1, 1, 1];
  3.  
  4. let mut neg_one_locations = Vec::new();
  5. let mut zero_locations = Vec::new();
  6. let mut pos_one_locations = Vec::new();
  7.  
  8. for i in input.iter() {
  9. match input[i] {
  10. -1 => neg_one_locations.push(i),
  11. 0 => zero_locations.push(i),
  12. 1 => pos_one_locations.push(i),
  13. }
  14. }
  15.  
  16. println!(
  17. "Negatives locations: {:?}, Zeros locations: {:?}, Positives locations: {:?}",
  18. neg_one_locations, zero_locations, pos_one_locations
  19. );
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement