diff options
| author | Mitsuo Tokumori <[email protected]> | 2022-12-04 23:13:28 -0500 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2022-12-04 23:13:28 -0500 |
| commit | 8e01ba134a230e47e8b80351dd8abc8c3b72e683 (patch) | |
| tree | 3f0e174c80cc4a6e4a2aa2b5351f4dad66b49d89 /2022-2/L10/mitsuo/aux.h | |
| parent | ce58d6504665422a0817cf0ddb38fc533d0de33e (diff) | |
| download | LP1-8e01ba134a230e47e8b80351dd8abc8c3b72e683.tar.gz LP1-8e01ba134a230e47e8b80351dd8abc8c3b72e683.tar.bz2 LP1-8e01ba134a230e47e8b80351dd8abc8c3b72e683.zip | |
Add my solution for L10
Diffstat (limited to '2022-2/L10/mitsuo/aux.h')
| -rw-r--r-- | 2022-2/L10/mitsuo/aux.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/2022-2/L10/mitsuo/aux.h b/2022-2/L10/mitsuo/aux.h new file mode 100644 index 0000000..04df37c --- /dev/null +++ b/2022-2/L10/mitsuo/aux.h @@ -0,0 +1,34 @@ +/* + * File: aux.h + * Author: mitsuo + * + * Created on 27 November 2022, 11:48 + */ + +#ifndef AUX_H +#define AUX_H + +// The parenthesis in C/C++ macros are best practice +// https://stackoverflow.com/q/7186504/7498073 + +// Width-Left (use with strings) +#define WL(w) " " << setw((w) - 1) << left << setprecision(2) << fixed + +// Width-Right (use with numbers) +#define WR(w) setw(w) << right << setprecision(2) << fixed + +// Width-Right-0-padding +#define WR0(w, w0, x) setw((w) - (w0)) << "" \ + << setw(w0) << right << setfill('0') \ + << setprecision(2) << fixed << (x) \ + << setfill(' ') + +// Width-Left-Date (dd/mm/yyyy format) +#define WLD(w, x) setw((w) - 10) << "" << WR0(2, 2, (x) % 100) \ + << '/' << WR0(2, 2, (x) / 100 % 100) \ + << '/' << WR0(4, 4, (x) / 10000) + +#define MAXLEN 100 + +#endif /* AUX_H */ + |
