diff options
| author | Mitsuo Tokumori <[email protected]> | 2023-08-18 01:57:48 -0500 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2023-08-18 01:57:48 -0500 |
| commit | 387642ff612de7d0ebf09410cd8e39a4765c877a (patch) | |
| tree | 38c6160cca0ba4cfae966a74d839dd18efdf099a /2023-2/L0/fun.cpp | |
| parent | 49d4392ca1972c8d66b1015f2cdda414d94812b8 (diff) | |
| download | LP1-387642ff612de7d0ebf09410cd8e39a4765c877a.tar.gz LP1-387642ff612de7d0ebf09410cd8e39a4765c877a.tar.bz2 LP1-387642ff612de7d0ebf09410cd8e39a4765c877a.zip | |
Fix naming. Add leading 0 to lab names
Diffstat (limited to '2023-2/L0/fun.cpp')
| -rw-r--r-- | 2023-2/L0/fun.cpp | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/2023-2/L0/fun.cpp b/2023-2/L0/fun.cpp deleted file mode 100644 index e317db3..0000000 --- a/2023-2/L0/fun.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include <iostream> // I/O basico (left, right, hex, oct, [no]uppercase, showbase) -#include <iomanip> // manipuladores (setw, setprecision, setfill) -#include <iostream> -#include <cstring> -#include "fun.h" - -#define MAXLEN 100 - -using namespace std; - -void leer_datos_escribir_reporte(std::istream& in, std::ostream& out) { - int sum_qty; - double sum_price; // (price * qty) - - char code[MAXLEN]; - char book_name[MAXLEN]; - char author_name[MAXLEN]; - int qty; - double unit_price; - char c; // dummy - - sum_qty = 0; - sum_price = 0.0; - print_header(out); - int i; - for (i = 0; true; i++) { - // read - in.getline(code, MAXLEN, ','); - in.getline(book_name, MAXLEN, ','); - in.getline(author_name, MAXLEN, ','); - in >> qty; - in >> c; - in >> unit_price; - in.ignore(MAXLEN, '\n'); - if (!in) { - break; - } - // process - to_upper_cstring_inplace(book_name); - sum_qty += qty; - sum_price += qty * unit_price; - - // write - out << setw(2) << right << setfill('0') << i + 1 << ") "; - out << left << setfill(' '); - out << setw(8) << code; - out << setw(32) << uppercase << book_name; - out << setw(32) << author_name; - out << right << setprecision(2) << fixed; - out << setw(4) << qty; - out << setw(4) << ' '; - out << setw(8) << unit_price; - out << '\n'; - } - - out << "\n\n"; - out << "Total cantidad libros: " << sum_qty << '\n'; - out << "Total valor libros: " << sum_price << '\n'; -} - -void print_header(ostream& out) { - // 8 32 32 4 8 - out << "No. Codigo Nombre Autor Cant. Precio \n"; - out << "----------------------------------------------------------------------------------------------\n"; -} - -void to_upper_cstring_inplace(char * s) { - int i; - for (i = 0; s[i] != '\0'; i++) { - s[i] = toupper(s[i]); - } -}
\ No newline at end of file |
