Solve 3 plz plz in CSolutionC code sort list include include

Solve 3 plz plz in C++

Solution

//C code sort list

#include <stdio.h>
#include <stdlib.h>

// structure for node of list
struct node
{
double data;
struct node *next;
};

// insert node
void push(struct node** head, double value)
{
struct node* new = (struct node*) malloc(sizeof(struct node));
new->data = value;
new->next = (*head);
(*head) = new;
}

// swap data
void swapfunction(struct node *a, struct node *b)
{
double temp = a->data;
a->data = b->data;
b->data = temp;
}


// sort list
void sortList(struct node *head)
{
double boolswap, i;
struct node *firstpointer;
struct node *lastpointer = NULL;

if (firstpointer == NULL)
return;

do
{
boolswap = 0;
firstpointer = head;

while (firstpointer->next != lastpointer)
{
if (firstpointer->data < firstpointer->next->data)
{
swapfunction(firstpointer, firstpointer->next);
boolswap = 1;
}
firstpointer = firstpointer->next;
}
lastpointer = firstpointer;
}
while (boolswap);
}

int main()
{
struct node *a = NULL;

push(&a, 24.56);
push(&a, 25.37);
push(&a, 11.59);
push(&a, 34.76);
push(&a, 35.11);

sortList(a);

printf(\"\ \");
while (a!=NULL)
{
printf(\"%0.2lf\ \", a->data);
a = a->next;
}

printf(\"\ Actually I modified the function implementation files in the program\ \");
return 0;
}


/*
output:


35.11
34.76
25.37
24.56
11.59

Actually I modified the function implementation files in the program


*/

Solve 3 plz plz in C++Solution//C code sort list #include <stdio.h> #include <stdlib.h> // structure for node of list struct node { double data; str
Solve 3 plz plz in C++Solution//C code sort list #include <stdio.h> #include <stdlib.h> // structure for node of list struct node { double data; str

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site