Created
March 1, 2018 23:53
-
-
Save Haguilar91/07a23bdd7dc6507a517775ba2bd07dcb 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 "stdafx.h" | |
#include <cstdlib> | |
#include <iostream> | |
#include "Lista.h" | |
#include <string> | |
using namespace std; | |
Lista::Lista() { | |
inicio = NULL; | |
fin = NULL; | |
contar = 0; | |
} | |
/*void Lista::agregarNodo(int agrDato, string etiquet) { | |
if (contar == 0) | |
{ | |
nodoPtr n = new Nodo; //creando un nuevo nodo | |
n->anterior = NULL; | |
n->dato = agrDato; | |
n->etiqueta = etiquet; | |
inicio = n; | |
fin = n; | |
contar++; | |
} | |
else{ | |
//Cuando no es el primer nodo | |
nodoPtr n = new Nodo; //creando un nuevo nodo | |
n->anterior = fin; | |
fin->siguiente = n; | |
n->dato = agrDato; | |
n->etiqueta = etiquet; | |
contar++; | |
} | |
}*/ | |
struct Lista::Nodo* 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 = NULL; | |
n->etiqueta = i+j; | |
inicio = n; | |
fin = n; | |
contar++; | |
} | |
else { | |
//Cuando no es el primer nodo | |
nodoPtr n = new Nodo; //creando un nuevo nodo | |
n->anterior = fin; | |
fin->siguiente = n; | |
n->dato = NULL; | |
n->etiqueta = i+j; | |
contar++; | |
} | |
} | |
} | |
cout << contar << " Nodos, fueron creados" << endl; | |
return inicio; | |
} | |
void Lista::imprimirMatriz(Nodo* cabeza) | |
{ | |
Nodo* temp = cabeza; | |
for (int x = 0; x<25; x++) | |
{ | |
cout << temp->etiqueta << " "; | |
temp = temp->siguiente; | |
} | |
/* | |
cout << " A B C D E" << endl; | |
for (int x = 0; x < 5; x++) { | |
cout<< x + 1 <<" "; | |
for (int y = 0; y < 5; y++) { | |
cout << temp->etiqueta <<" "; | |
if (y == 4) { | |
cout << endl; | |
temp = temp->siguiente; | |
} | |
else { | |
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: hagui | |
* | |
* 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; //typedef struct Nodo* nodePtr; | |
nodoPtr inicio; | |
nodoPtr fin; | |
int contar; | |
public: //Aqui van las funciones | |
Lista(); | |
//void agregarNodo(int agrDato, std::string etique); | |
//void borrarNodo(int borrDato); | |
void imprimirMatriz(Nodo* cabeza); | |
struct Nodo* 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 "stdafx.h" | |
#include <cstdlib> | |
#include <iostream> | |
#include "Lista.h" | |
using namespace std; | |
int main() | |
{ | |
Lista matriz; | |
int numero; | |
string etiquet; | |
string formula; | |
string pos; | |
//cout << "Que posicion?" << endl; | |
//cin >> pos; | |
//cout << "Que operacion?" << endl; | |
//cout << "Introducir Valor" << endl; | |
//cin >> numero; | |
//cout << "Introducir Etiqueta" << endl; | |
//cin >> etiquet; | |
Lista::Nodo* var1 = matriz.crearMatriz(); | |
matriz.imprimirMatriz(var1); | |
system("PAUSE"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment