Created
March 3, 2018 01:22
-
-
Save Haguilar91/0faa5640b022b63a9b3cac2c3d3b8ba1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/* | |
* File: Lista.cpp | |
* Author: hagui | |
* | |
* Created on February 26, 2018, 8:44 PM | |
*/ | |
#include <cstdlib> | |
#include <iostream> | |
#include "Lista.h" | |
#include <string> | |
using namespace std; | |
Lista::Lista() { | |
inicio = NULL; | |
fin = NULL; | |
contar = 0; | |
} | |
void Lista::crearMatriz() | |
{ | |
for (int i = 0; i < 5; i++) | |
{ | |
for (int j = 0; j < 5; j++) | |
{ | |
if (contar == 0) | |
{ | |
nodoPtr n = new Nodo; //creando un nuevo nodo | |
n->anterior = NULL; | |
n->dato = 0; | |
n->etiqueta = std::to_string(i+1) + std::to_string(j+1); | |
inicio = n; | |
fin = n; | |
contar++; | |
cout << "Etiqueta Primer Nodo" << n->etiqueta << endl; | |
}else | |
if(contar==24){ | |
nodoPtr n = new Nodo; //creando un nuevo nodo | |
n->anterior = fin; | |
fin=n; | |
n->siguiente = NULL; | |
n->dato = 0; | |
n->etiqueta = std::to_string(i+1) + std::to_string(j+1); | |
cout << "Etiqueta Nodo Final" << contar << " " << n->etiqueta << endl; | |
contar++; | |
} | |
else { | |
//Cuando no es el primer nodo | |
nodoPtr n = new Nodo; //creando un nuevo nodo | |
n->anterior = fin; | |
fin->siguiente = n; | |
n->dato = 0; | |
n->etiqueta = std::to_string(i+1) + std::to_string(j+1); | |
cout << "Etiqueta" << contar << " " << n->etiqueta << endl; | |
contar++; | |
} | |
} | |
} | |
cout << contar << " Nodos, fueron creados" << endl; | |
} | |
void Lista::imprimirMatriz() | |
{ | |
nodoPtr temp = inicio; | |
cout<<"Entre: "<<temp->etiqueta<<endl; | |
cout<<"Cuanto "<<contar<<endl; | |
while(temp!=NULL){ | |
cout << "Nodo" << temp->etiqueta << " "<<endl; | |
temp = temp->siguiente; | |
} | |
/* | |
for (int x = 0; x<25; x++) | |
{ | |
if(x==24){ | |
cout<<"Ultimo Ciclo"<<endl; | |
}else{ | |
cout<<"Ciclo: "<<x<<endl; | |
cout << temp->etiqueta << " "<<endl; | |
temp = temp->siguiente; | |
} | |
}*/ | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/* | |
* File: Lista.h | |
* Author: Nancy R. | |
* | |
* Created on February 26, 2018, 9:09 PM | |
*/ | |
#ifndef LISTA_H | |
#define LISTA_H | |
class Lista { | |
public: | |
typedef struct Nodo { | |
int dato; | |
std::string etiqueta; | |
Nodo* siguiente; | |
Nodo* anterior; | |
}*nodoPtr; | |
nodoPtr inicio; | |
nodoPtr fin; | |
int contar; | |
//Aqui van las funciones | |
Lista(); | |
//typedef struct Nodo* nodePtr; | |
//void agregarNodo(int agrDato, std::string etique); | |
//void borrarNodo(int borrDato); | |
void imprimirMatriz(); | |
void crearMatriz(); | |
}; | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
#ifdef __cplusplus | |
} | |
#endif | |
#endif /* LISTA_H */ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Main.cpp : Defines the entry point for the console application. | |
// | |
#include <cstdlib> | |
#include <iostream> | |
#include "Lista.h" | |
using namespace std; | |
int main() | |
{ | |
Lista matriz; | |
matriz.crearMatriz(); | |
matriz.imprimirMatriz(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment