Contare i pacchi dopo una consegna
Aggiungere quello che è entrato, poi sottrarre quello che è uscito.
Esempio semplice
All’inizio2 + 3 − 1
Risultato4
const std = @import("std");
fn show(value: i64) !void {
var buffer: [64]u8 = undefined;
var writer = std.fs.File.stdout().writer(&buffer);
try writer.interface.print("{d}\n", .{value});
try writer.interface.flush();
}
pub fn main() !void {
try show(((2 + 3) - 1));
}
4
Annunci
Esempi di vita quotidiana
Due scatole tengono 6 e 4 pacchi. Escono tre pacchi. Quanti sono rimasti?
All’inizio6 + 4 − 3
Risultato7
const std = @import("std");
fn show(value: i64) !void {
var buffer: [64]u8 = undefined;
var writer = std.fs.File.stdout().writer(&buffer);
try writer.interface.print("{d}\n", .{value});
try writer.interface.flush();
}
pub fn main() !void {
const first: i64 = 6;
const second: i64 = 4;
const sent: i64 = 3;
try show(((first + second) - sent));
}
7