Eliminar un nodo e imprimir los nodos restantes
Publicado por alex (2 intervenciones) el 17/02/2019 20:58:32
NECESITO QUE SE PUEDA ELIMINAR UN NODO E IMPRIMIR LOS NODOS RESTANTES COMO TENDRÍA QUE SER ???...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<iostream>
using namespace std;
struct nodo {
int dato;
nodo* sig;
};
void agregar(struct nodo* &p,int valor)
{
nodo* nuevo = new nodo;
nuevo->dato =valor;
nuevo->sig =NULL;
if (p==NULL){
p = nuevo;
}
else{
nodo* aux = p;
while (aux->sig !=NULL){
aux = aux->sig;
};
aux->sig = nuevo;
};
};
void borrar( struct nodo* &p,int valor ){
};
int main(){
nodo* p=NULL;
agregar(p,3);// p ya no es nulo cuando sale
agregar(p,5);
agregar(p,8);
cout<<p;
cout<<p;
cout<<p;
limpiar(p,3);//limpiar y que imprima los valores, funcion que borre un elemento (nodo)
return 0;
}
Valora esta pregunta
0