Pagini recente » Cod sursa (job #854790) | Cod sursa (job #2922222) | Cod sursa (job #1347295) | Cod sursa (job #1987268) | Cod sursa (job #2663262)
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();
}