Cod sursa(job #3187205)

Utilizator susdomesticussusdomesticus susdomesticus Data 28 decembrie 2023 01:09:23
Problema A+B Scor 0
Compilator rs Status done
Runda Arhiva de probleme Marime 0.58 kb
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("adaugare.out", sum.to_string()).expect("Program should be able to write to the output file")
}