Scanf.scanf "%d" (fun abcd ->
    let a = abcd            / 1000 in
    let b = (abcd mod 1000) /  100 in
    let c = (abcd mod  100) /   10 in
    let d = (abcd mod   10)        in
    if a + b + c + d = 7 then Printf.printf "%d+%d+%d+%d=7\n" a b c d else
    if a + b + c - d = 7 then Printf.printf "%d+%d+%d-%d=7\n" a b c d else
    if a + b - c + d = 7 then Printf.printf "%d+%d-%d+%d=7\n" a b c d else
    if a + b - c - d = 7 then Printf.printf "%d+%d-%d-%d=7\n" a b c d else
    if a - b + c + d = 7 then Printf.printf "%d-%d+%d+%d=7\n" a b c d else
    if a - b + c - d = 7 then Printf.printf "%d-%d+%d-%d=7\n" a b c d else
    if a - b - c + d = 7 then Printf.printf "%d-%d-%d+%d=7\n" a b c d else
    if a - b - c - d = 7 then Printf.printf "%d-%d-%d-%d=7\n" a b c d else ()
)