I gang

Linked Lists

struct Donut {

string flavor = "Chocolate";

double price = 0.0;

Donut* next = NULL;

Donut(){}

Donut(string flavor, double price) {

this->flavor = flavor;

this->price = price;

}

void display() {

cout << flavor << "\t$" << price << endl;

}

};

void appendDonut(Donut* head, Donut* donut) - appends donut structure referenced by pointer donut to the end of the list referenced by pointer head

void displayList(Donut* head) - iterates over the list referenced by pointer head displaying each of the donuts by using the donut’s display() method

int lengthOfList(Donut* head) - iterates over the list referenced by pointer head counting how many donuts there are in the list and returns the count

Donut* findFirstDonutFlavor(Donut* head, string flavor) - iterates over the list referenced by pointer head comparing the string parameters flavor with each of the donut’s flavor member variable. If found it returns the pointer to the donut where it was found. Otherwise returns NULL

Sample Output

[0] Chocolate $[url removed, login to view]

[1] Boston Crm $[url removed, login to view]

[2] Jelly $[url removed, login to view]

[3] Glazed $[url removed, login to view]

[4] Eclair $[url removed, login to view]

[5] Snowy $[url removed, login to view]

[6] Glazed $[url removed, login to view]

[7] Moonraker $[url removed, login to view]

8 Donuts

Found Donut:

Glazed $[url removed, login to view]

Færdigheder: C++ Programmering

Se mere: method crm, linked it, linked int, endl, donuts, double linked list, list double linked, struct, price lists sample, comparing lists, linked lists, list linked, subtracting numbers linked lists, projects linked lists, recursive linked lists, java double linked lists, java doubly linked lists

Om arbejdsgiveren:
( 22 bedømmelser ) Cambridge, United States

Projekt-ID: #6021995

Tildelt til:

PeinOS

Hired by the Employer

$15 USD på 1 dag
(4 bedømmelser)
1.5