Skip to content

Instantly share code, notes, and snippets.

@alex-pat
Created July 11, 2017 19:25
Show Gist options
  • Save alex-pat/d4e68e53b2b0b2750e45ec278c477f76 to your computer and use it in GitHub Desktop.
Save alex-pat/d4e68e53b2b0b2750e45ec278c477f76 to your computer and use it in GitHub Desktop.
use std::io::prelude::*;
use std::collections::HashMap;
fn main() {
let mut input = String::new();
std::io::stdin().read_to_string(&mut input).unwrap();
let mut input_words = input.split_whitespace();
let n: u32 = input_words.next().unwrap().parse().unwrap();
let mut hashmap = HashMap::new();
for _ in 0..n {
let key = input_words.next().unwrap();
let value: u32 = input_words.next().unwrap().parse().unwrap();
hashmap.insert(key, value);
}
for key in input_words {
match hashmap.get(key) {
Some(value) => println!("{}={}", key, value),
None => println!("Not found"),
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment