Pagini recente » Cod sursa (job #789195) | Cod sursa (job #2417221) | Cod sursa (job #1949358) | Cod sursa (job #310907) | Cod sursa (job #3187206)
use std::fs;
fn main() {
// Read input file and parse numbers
let str = fs::read_to_string("adunare.in").expect("Input file should always exist!");
let lines: Vec<&str> = str.lines().collect();
let a: i32 = lines[0].parse().expect("Input file should contain numbers on the first two lines");
let b: i32 = lines[1].parse().expect("Input file should contain numbers on the first two lines");
// Calculate sum
let sum = a + b;
// Write to the output file
fs::write("adunare.out", sum.to_string()).expect("Program should be able to write to the output file")
}