From 49d4392ca1972c8d66b1015f2cdda414d94812b8 Mon Sep 17 00:00:00 2001 From: Mitsuo Tokumori Date: Fri, 18 Aug 2023 01:56:52 -0500 Subject: Fix naming. Add leading 0 to lab names --- 2022-2/L01/mitsuo/aux.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 2022-2/L01/mitsuo/aux.cpp (limited to '2022-2/L01/mitsuo/aux.cpp') diff --git a/2022-2/L01/mitsuo/aux.cpp b/2022-2/L01/mitsuo/aux.cpp new file mode 100644 index 0000000..bd9417d --- /dev/null +++ b/2022-2/L01/mitsuo/aux.cpp @@ -0,0 +1,37 @@ +/* Auxiliary/helper/reusable functions */ + +#include +#include + +#include "aux.h" + +using namespace std; + +/* "dd/mm/yyyy" -> yyyymmdd (int) */ +int readdate(istream &is) +{ + char c; + int d, m, y; + + is >> d >> c + >> m >> c + >> y; + + return y * 10000 + m * 100 + d; +} + +/* yyyymmdd (int) -> "dd/mm/yyyy" */ +void writedate(ostream &os, int intdate) +{ + int d, m, y; + + d = intdate % 100; + intdate /= 100; + m = intdate % 100; + intdate /= 100; + y = intdate; + + os << WR0(2, 2, y) << '/' + << WR0(2, 2, m) << '/' + << WR0(2, 2, d) << '\n'; +} -- cgit v1.2.3