2
How do I display the values entered in a Double Chained Circular List?
Follow my code with my attempt:
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <malloc.h>
#include <conio.h>
using namespace std;
int x, num;
struct lista
{
    int valor;
    struct lista * prox;
    struct lista * ant;
};
struct lista * inicio;
struct lista * fim;
struct lista * aux;
//Insere na lista o número passado por parãmetro
void insere(int valor)
{
    aux = (struct lista *)malloc(sizeof(struct lista));
    aux->valor = valor;
    aux->prox = NULL;
    aux->ant = NULL;
    if (inicio == NULL)
    {
        inicio = aux;
    }
    else
    {
        fim->prox = aux;
        aux->ant = fim;
    }
    fim = aux;
    fim->prox;
    inicio->ant = fim;
}
//Mostra todos os elementos da lista
void exibirElementos()
{ 
    while (1)
    {
        cout << inicio->valor;
        inicio->prox;
        if (inicio->prox->valor == fim->valor)
            break;
    }
}
int main()
{
    inicio = NULL;
    fim = NULL;
    aux = NULL;
}
The method that is responsible for displaying the values is exibirElementos().
I’m using the Visual Studio 2013 to compile.
I can post a pseudo-code?
– Enzo Tiezzi
@Enzotiezzi Can yes.
– Leonardo