Как упорядочить элементы списка в С++?

Моя задача - создать список из элементов массива, после чего упорядочить его по элементам. Но я не знаю, как это сделать. Удалось только создать список. Вот код:

using namespace  std;

#define STOP 0.0

typedef struct Node* Point;

struct  Node
{
    double info;
    Point link;
};


void Push(Point* top, double);
void WriteStack(Point* top, double[]);

void ReadStack(Point top);


int main()
{
    Point top;
    top = NULL;

    double list[4] = { 1, 4, 5, 3 };
    cout <<"\n\nInputted array is:\n{" << list[0]<< endl << list[1] << endl << list[2] << endl << list[3]<<'}';
    WriteStack(&top, list);
    cout << "\n\nStack is " << endl;
    ReadStack(top);

    system("pause");
    return 0;
}

void Push(Point* top, double c)
{
    Point new_top;
    new_top = new (Node);
    new_top->info = c;
    new_top->link = *top;
    *top = new_top;
}
void WriteStack(Point* top, double list[])
{
    double c;
    int count = 0;
    for (int i = 0; i < 4; i++)
    {
        c = list[3-count];
        Push(top, c);
        count++;
    }
}


int EofStack(Point top)
{
    return top == NULL;
}

void ReadTop(Point* top, double* c)
{
    *c = (*top)->info;
    *top = (*top)->link;
}


void ReadTop1(Point* top, double* c)
{
    *top = (*top)->link;

    if (*top != NULL)
        *c = (*top)->info;
}




void ReadStack(Point top)
{
    double c;
    while (!EofStack(top))
    {

        ReadTop(&top, &c);
        cout << c << endl;
    }
}

Ответы (0 шт):