Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.05 KB | None | 0 0
  1. use std::io::BufRead;
  2. use std::io;
  3. use std::string::String;
  4. // use std::error::Error;
  5. // use std::io::prelude::*;
  6.  
  7. fn main() {
  8.     let mut x = (0, 0, 0);
  9.  
  10.     let mut i = 1;
  11.  
  12.     let reader = io::stdin();
  13.     for line in reader.lock().lines() {
  14.         match i {
  15.             // First line
  16.             1 => {
  17.                 let x = parse_header(line.unwrap());
  18.             },
  19.             _ => {
  20.                 println!("Content was {}", line.unwrap());
  21.             },
  22.         }
  23.         i += 1;
  24.     }
  25.     let (length, words_count, tests_count) = x;
  26.     println!("length = {}, words_count = {}, tests_count = {}", length, words_count, tests_count);
  27.  
  28.     let words_matched = 15;
  29.  
  30.     println!("Case #{}: {}", 1, words_matched);
  31. }
  32.  
  33. fn parse_header(line: String) -> (i32, i32, i32) {
  34.     let split_values: Vec<&str> = line.split(" ").collect();
  35.     let length = split_values[0].parse::<i32>();
  36.     let words = split_values[1].parse::<i32>();
  37.     let tests = split_values[2].parse::<i32>();
  38.     (length.unwrap(), words.unwrap(), tests.unwrap())
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement