summaryrefslogtreecommitdiffstats
path: root/2022-2/L6/mitsuo
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/L6/mitsuo
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/L6/mitsuo')
-rw-r--r--2022-2/L6/mitsuo/BibliotecaPilaGenerica.cpp99
-rw-r--r--2022-2/L6/mitsuo/BibliotecaPilaGenerica.h14
-rw-r--r--2022-2/L6/mitsuo/Makefile16
-rw-r--r--2022-2/L6/mitsuo/Medicinas.csv25
-rw-r--r--2022-2/L6/mitsuo/PilaConEnteros.h0
-rw-r--r--2022-2/L6/mitsuo/PilaConRegistros.h0
-rw-r--r--2022-2/L6/mitsuo/fun.cpp69
-rw-r--r--2022-2/L6/mitsuo/fun.h11
-rw-r--r--2022-2/L6/mitsuo/main.cpp27
-rw-r--r--2022-2/L6/mitsuo/numeros.txt3
-rw-r--r--2022-2/L6/mitsuo/repnumeros.txt0
11 files changed, 0 insertions, 264 deletions
diff --git a/2022-2/L6/mitsuo/BibliotecaPilaGenerica.cpp b/2022-2/L6/mitsuo/BibliotecaPilaGenerica.cpp
deleted file mode 100644
index 01a7dc3..0000000
--- a/2022-2/L6/mitsuo/BibliotecaPilaGenerica.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include "BibliotecaPilaGenerica.h"
-
-using namespace std;
-
-/* NEXT: (void *), DATA: (int *) */
-enum nodeIndices { NEXT, DATA };
-
-void cargapila(void *&pila, void *arreglo)
-{
- int i;
- int **numbers = (int **) arreglo;
- pila = nullptr;
- for (i = 0; numbers[i]; i++) {
- push(pila, numbers[i]);
- }
-}
-
-void push(void *&pila, void *data)
-{
- void **node = new void * [2];
- node[NEXT] = pila;
- node[DATA] = data;
- pila = node;
-}
-
-void *pop(void *&pila)
-{
- void **node;
- if (pila == nullptr) {
- return nullptr;
- } else {
- node = (void **) pila;
- pila = node[NEXT];
- return node[DATA];
- }
-}
-
-int pilavacia(void *pila)
-{
- return pila == nullptr;
-}
-
-void imprimepila(
- void *pila,
- void (*imprimenumero)(ostream &out, void *),
- const char *filename
-) {
- ofstream out(filename);
- if (!out) {
- cerr << "Error: no se pudo abrir archivo\n";
- }
- void **next;
- void **node;
- int data;
-
- next = (void **) pila;
- while (next) {
- node = (void **) next;
- imprimenumero(out, node[DATA]);
-
- next = (void **) node[NEXT];
- }
-}
-
-/* hanoi */
-void muevepila(void *pilasrc, void *&piladest)
-{
- void *pilaaux = nullptr;
-
- /* count elements */
- int i = 0;
- void **next = (void **) pilasrc;
- while (next) {
- next = (void **) *next;
- i++;
- }
- // cout << "n = " << i << '\n';
- hanoi(i, pilasrc, nullptr, piladest);
-}
-
-static void hanoi(int n, void *pila1, void *pila2, void *pila3)
-{
- /* FIXME: I don't know where it's the bug. Here or in pop(). Also the stack
- * representation different from what is asked in the problem statement */
- void *data;
- if (n == 0) {
- return;
- } else if (n == 1) {
- data = pop(pila1);
- push(pila3, data);
- } else {
- hanoi(n - 1, pila1, pila3, pila2);
- data = pop(pila1);
- push(pila3, data);
- hanoi(n - 1, pila2, pila1, pila3);
- }
-}
diff --git a/2022-2/L6/mitsuo/BibliotecaPilaGenerica.h b/2022-2/L6/mitsuo/BibliotecaPilaGenerica.h
deleted file mode 100644
index 4fed61f..0000000
--- a/2022-2/L6/mitsuo/BibliotecaPilaGenerica.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <iostream>
-
-void cargapila(void *&pila, void *arreglo);
-void push(void *&pila, void *data);
-void *pop(void *&pila);
-int pilavacia(void *pila);
-void imprimepila(
- void *pila,
- void (*imprimenumero)(std::ostream &out, void *),
- const char *filename
-);
-void muevepila(void *pilasrc, void *&piladest);
-
-static void hanoi(int n, void *pila1, void *pila2, void *pila3);
diff --git a/2022-2/L6/mitsuo/Makefile b/2022-2/L6/mitsuo/Makefile
deleted file mode 100644
index f8bcb92..0000000
--- a/2022-2/L6/mitsuo/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Just a simple C++ makefile
-#
-# Use with `$ make`
-# Run build binary with `$ ./a.out`
-
-
-# No file association to the "clean" target. Also no dependency.
-# See more: https://stackoverflow.com/a/2145605/7498073
-.PHONY: all
-all:
- clang++ -g *.cpp && ./a.out
-
-
-.PHONY: clean
-clean:
- rm *.o a.out
diff --git a/2022-2/L6/mitsuo/Medicinas.csv b/2022-2/L6/mitsuo/Medicinas.csv
deleted file mode 100644
index b53f86c..0000000
--- a/2022-2/L6/mitsuo/Medicinas.csv
+++ /dev/null
@@ -1,25 +0,0 @@
-60509,AMPICILINA 125MG SUSP 90ML,58.65
-73972,VITAMINA E 400 MG C90 CAPS,54.4
-94429,TIAMAZOL 5MG 20T,52.7
-43709,CEFUROXIMA 250MG SUSP,78.2
-82469,GUAYACOL AMPOLLETA 1ML,60.35
-93578,SUCRALFATO 40 TAB/1G,55.25
-26484,DILTIAZEM 30 TAB/30 MG,29.75
-95196,DIGOXINA 0.250 MG C/24,62.05
-65667,SUBSALICILATO/BISMUTO SUSP 120ML,61.2
-94415,PRAVASTATINA 10 MG C/15,68.85
-11370,KETOROLACO 4T 30MG SUBLINGUAL,2.55
-49644,HIDROCORTISONA CRA 30GR,73.95
-76238,BEZOCAINA 10GR GEL,56.95
-79189,CLORFENAMINA 4MG T20,73.1
-81333,CARNITINA C/30,40.8
-33311,ALBENDAZOL 200MG C/6 TAB,20.4
-62302,BEZAFIBRATO 200MG C/30TAB,41.65
-72495,ACIDO GLUTAMICO 600 MG C/100,43.35
-16813,VANCOMICINA 500MG SOL INY,5.95
-36711,TIBOLONA 2.5MG 30T,84.15
-55021,AMOXICILINA 500MG/5ML SUSP,82.45
-34080,ELECTROLIT FRESA 500ML,60.35
-36622,TEOFILINA 20 TAB/100 MG,57.8
-72969,ISOSORBIDE 10MG T/20,58.65
-40997,ELECTROLIT PED FRESA 625ML,41.65
diff --git a/2022-2/L6/mitsuo/PilaConEnteros.h b/2022-2/L6/mitsuo/PilaConEnteros.h
deleted file mode 100644
index e69de29..0000000
--- a/2022-2/L6/mitsuo/PilaConEnteros.h
+++ /dev/null
diff --git a/2022-2/L6/mitsuo/PilaConRegistros.h b/2022-2/L6/mitsuo/PilaConRegistros.h
deleted file mode 100644
index e69de29..0000000
--- a/2022-2/L6/mitsuo/PilaConRegistros.h
+++ /dev/null
diff --git a/2022-2/L6/mitsuo/fun.cpp b/2022-2/L6/mitsuo/fun.cpp
deleted file mode 100644
index 569350c..0000000
--- a/2022-2/L6/mitsuo/fun.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-#include <cstdlib>
-#include <iostream>
-#include <fstream>
-#include <cstdlib>
-#include "fun.h"
-
-using namespace std;
-
-void cargaarreglo(void *&arreglo,
- int (*cmpnumero)(const void *, const void *),
- int *leenumero(istream &in),
- const char *filename)
-{
- ifstream in(filename);
-
- if (!in) {
- cerr << "Error, no se pudo abrir archivo\n";
- return;
- }
-
- int **numbers;
- int *data;
- int *buffer[MAXLEN];
- int i;
- /* load buffer */
- for (i = 0; (data = leenumero(in)); i++) {
- buffer[i] = data;
- }
- buffer[i] = nullptr;
-
- /* create "exact" array of pointers to int */
- numbers = new int * [i + 1];
- for (i = 0; buffer[i]; i++) {
- numbers[i] = buffer[i];
- }
- numbers[i] = nullptr;
-
- /* sort array */
-
- qsort(numbers, i, sizeof(void *), cmpnumero);
-
- // for (i = 0; numbers[i]; i++) {
- // cout << *numbers[i] << '\n';
- // }
-
- /* modify parameter reference */
- arreglo = numbers;
-}
-
-/* qsort comparisong function. Descending order */
-int cmpnumero(const void *p1, const void *p2)
-{
- return - (** (int **) p1 - ** (int **) p2);
-}
-
-/* allocates memory */
-int *leenumero(istream &in)
-{
- int n;
- if (in >> n)
- return new int{n};
- else
- return nullptr;
-}
-
-void imprimenumero(ostream &out, void *data)
-{
- cout << * (int *) data << '\n';
-}
diff --git a/2022-2/L6/mitsuo/fun.h b/2022-2/L6/mitsuo/fun.h
deleted file mode 100644
index aaa34c9..0000000
--- a/2022-2/L6/mitsuo/fun.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <iostream>
-
-#define MAXLEN 100
-
-int cmpnumero(const void *p1, const void *p2);
-int *leenumero(std::istream &in);
-void cargaarreglo(void *&arreglo,
- int (*cmpnumero)(const void *, const void *),
- int *leenumero(std::istream &in),
- const char *filename);
-void imprimenumero(std::ostream &out, void *data); \ No newline at end of file
diff --git a/2022-2/L6/mitsuo/main.cpp b/2022-2/L6/mitsuo/main.cpp
deleted file mode 100644
index 919fe1c..0000000
--- a/2022-2/L6/mitsuo/main.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Mitsuo Tokumori 20170895 */
-
-#include <iostream>
-
-#include "BibliotecaPilaGenerica.h"
-#include "PilaConEnteros.h"
-#include "PilaConRegistros.h"
-#include "fun.h"
-
-using namespace std;
-
-int main(int argc, char **argv)
-{
- void *arreglo, *pilaini, *pilafin;
-
- cargaarreglo(arreglo, cmpnumero, leenumero, "numeros.txt");
- cargapila(pilaini, arreglo);
- muevepila(pilaini, pilafin);
- imprimepila(pilafin, imprimenumero, "repnumeros.txt");
-// imprimepila(pilafin, imprimenumero, "repnumeros.txt");
-
-// cargaarreglo(arreglo, cmpregistro, leeregistro, "medicinas.csv");
-// cargapila(pilaini, arreglo);
-// muevepila(pilaini, pilafin);
-// imprimepila(pilafin, imprimeregistro, "repmedicinas.txt");
- return 0;
-} \ No newline at end of file
diff --git a/2022-2/L6/mitsuo/numeros.txt b/2022-2/L6/mitsuo/numeros.txt
deleted file mode 100644
index 9cae0c5..0000000
--- a/2022-2/L6/mitsuo/numeros.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-13
-4
-1
diff --git a/2022-2/L6/mitsuo/repnumeros.txt b/2022-2/L6/mitsuo/repnumeros.txt
deleted file mode 100644
index e69de29..0000000
--- a/2022-2/L6/mitsuo/repnumeros.txt
+++ /dev/null