#include <cstdlib>
#include <iostream>
//LISTA CIRCULAR
using namespace std;
struct listac{
int valor;
listac *sgte;
};
bool vacia(listac *inicio){
bool v=false;
if(inicio==NULL)
v=true;
return v;
}
void ingresar(listac *&inicio,listac *&ultimo){
cout<<"Ingrese un numero: ";
int numero;
listac *p;
p = new listac;
cin>>p->valor;
cout<<endl;
if(vacia(inicio)==true){
inicio=p;
ultimo=p; }
else{
inicio->sgte=p;
p->sgte=inicio;
ultimo=p;
}
}
void mostrar(listac *inicio,listac *ultimo){
listac *recorre , *aux;
recorre = inicio;
aux = recorre->sgte;
if(aux->sgte != inicio){
aux = recorre->sgte;
cout<<recorre->valor<<" ";
recorre=aux;
}
}
int main(int argc, char *argv[])
{
listac *inicio,*ultimo;
inicio=ultimo=NULL;
for(int i=1;i<=5;i++){
ingresar(inicio,ultimo);}
mostrar(inicio,ultimo);
system("PAUSE");
return EXIT_SUCCESS;
}