Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::io::BufRead;
- use std::io;
- use std::string::String;
- // use std::error::Error;
- // use std::io::prelude::*;
- fn main() {
- let mut x = (0, 0, 0);
- let mut i = 1;
- let reader = io::stdin();
- for line in reader.lock().lines() {
- match i {
- // First line
- 1 => {
- let x = parse_header(line.unwrap());
- },
- _ => {
- println!("Content was {}", line.unwrap());
- },
- }
- i += 1;
- }
- let (length, words_count, tests_count) = x;
- println!("length = {}, words_count = {}, tests_count = {}", length, words_count, tests_count);
- let words_matched = 15;
- println!("Case #{}: {}", 1, words_matched);
- }
- fn parse_header(line: String) -> (i32, i32, i32) {
- let split_values: Vec<&str> = line.split(" ").collect();
- let length = split_values[0].parse::<i32>();
- let words = split_values[1].parse::<i32>();
- let tests = split_values[2].parse::<i32>();
- (length.unwrap(), words.unwrap(), tests.unwrap())
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement