Cod sursa(job #2663262)

Utilizator livssKevin U livss Data 25 octombrie 2020 19:12:05
Problema A+B Scor 100
Compilator rs Status done
Runda Arhiva de probleme Marime 0.53 kb

use std::fs::File;
use std::path::Path;
use std::io::Write;

fn main() {
    let in_path = Path::new("adunare.in");
    let out_path = Path::new("adunare.out");

    let file_text = std::fs::read_to_string(in_path)
        .expect("file not found!");

    let lines: Vec<u32> = file_text.lines().map(|x| {
        let y: u32 = x.parse().unwrap();
        y
    }).collect();

    let sum = lines[0] + lines[1];
    let mut output_file_handle = File::create(out_path).unwrap();

    writeln!(&mut output_file_handle, "{}", sum).unwrap();
}