diff options
| author | Mitsuo Tokumori <[email protected]> | 2022-09-17 00:57:54 -0500 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2022-09-17 00:57:54 -0500 |
| commit | c571cb7df606206675311a773e4077a50f0c0ff2 (patch) | |
| tree | 275582f66df247742a3f52c5afbf9ab1c1631c58 /2022-2/L1/mitsuo/aux.h | |
| parent | 4d0f0e9b8152efe2cf91afc17986a67c7bd55954 (diff) | |
| download | LP1-c571cb7df606206675311a773e4077a50f0c0ff2.tar.gz LP1-c571cb7df606206675311a773e4077a50f0c0ff2.tar.bz2 LP1-c571cb7df606206675311a773e4077a50f0c0ff2.zip | |
L1 completo. No tan "succinct" que digamos, pero
Las macros de los stream manipulators ahorran mucho codigo.
Definitivamente voy a reusar eso para las siguientes resoluciones.
Aun hay muchos aspectos en que mejorar.
En cuestion de tiempos, la parte basica la acabe en 1h 40m mas o menos,
pero de ahi en hacer las macros, re-leer la fecha como enteros, todo
lo de los contadores, y perfeccionando el formato, me demore unas 2-3h
mas. Tambien es el primer lab de C++ que resuelvo desde hace 2 aƱos.
Definitivamente este curso es pura practica, entender los casos tipo,
entender la menera que el profesor quiere que se codifique y no perder
el foco en la solucion.
Me interesa hacer una solucion en python a ver cuanto tiempo y lineas de
codigo se ahorra...
Diffstat (limited to '2022-2/L1/mitsuo/aux.h')
| -rw-r--r-- | 2022-2/L1/mitsuo/aux.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/2022-2/L1/mitsuo/aux.h b/2022-2/L1/mitsuo/aux.h new file mode 100644 index 0000000..ceb1ff3 --- /dev/null +++ b/2022-2/L1/mitsuo/aux.h @@ -0,0 +1,30 @@ +/* Stream manipulator macros + * ========================= */ + +// The parenthesis in C/C++ macros are best practice +// https://stackoverflow.com/q/7186504/7498073 + +// string +// (add space in front to separate adjacent right-aligned and left-aligned +// fields) +#define WL(w) " " << setw((w)-1) << left << setprecision(2) << fixed + +// number +#define WR(w) setw(w) << right << setprecision(2) << fixed + +// number with some 0-padding part (e.g., a code) +#define WR0(w, w0, x) setw((w) - (w0)) << "" \ + << setw(w0) << right << setfill('0') \ + << setprecision(2) << fixed << (x) \ + << setfill(' ') + + +/* Project definitions */ + +#define MAXLEN 100 // fixed length strings + + +/* Function declarations */ + +int readdate(std::istream &is); +void writedate(std::ostream &os, int intdate); |
