summaryrefslogtreecommitdiffstats
path: root/2022-2/L01/mitsuo/aux.cpp
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2023-08-18 01:56:52 -0500
committerMitsuo Tokumori <[email protected]>2023-08-18 01:56:52 -0500
commit49d4392ca1972c8d66b1015f2cdda414d94812b8 (patch)
tree13585bcb546d97b96ec669457c06fc27f2d66ab7 /2022-2/L01/mitsuo/aux.cpp
parentd6e56dbe184cac37d7aa5cebe3e1db108dee4a28 (diff)
downloadLP1-49d4392ca1972c8d66b1015f2cdda414d94812b8.tar.gz
LP1-49d4392ca1972c8d66b1015f2cdda414d94812b8.tar.bz2
LP1-49d4392ca1972c8d66b1015f2cdda414d94812b8.zip
Fix naming. Add leading 0 to lab names
Diffstat (limited to '2022-2/L01/mitsuo/aux.cpp')
-rw-r--r--2022-2/L01/mitsuo/aux.cpp37
1 files changed, 37 insertions, 0 deletions
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 <iostream>
+#include <iomanip>
+
+#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';
+}