Homework 4.cpp - /*#include<iostream> using namespace std;...

This preview shows page 1 - 3 out of 8 pages.

The preview shows page 1 - 3 out of 8 pages.
/*#include<iostream>using namespace std;struct doubleList{int data;struct doubleList *link;};doubleList* doubleList(doubleList* front){if(front==NULL){return NULL;}doubleList* c=front,*prev=front;doubleList* newList=new doubleList();newList->data=front->data;newList->next=NULL;doubleList* p=newList;c=c->next;while(c!=NULL){prev=c;doubleList* node= new doubleList();node->data=c->data;node->next=NULL;p->next=node;p=node;c=c->next;}prev->next=newList;return front;}int main(){doubleList *front = new doubleList();doubleList *second = new doubleList();doubleList *third = new doubleList();doubleList *forth = new doubleList();doubleList *fifth = new doubleList();front->data = 8;front->link = second;second->data = 23;second->link = third;third->data = 19;third->link = forth;forth->data = 7;forth->link = fifth;fifth->data = 102;fifth->link = NULL;doubleList(front);}*/
//Problem 13/*#include <iostream>using namespace std;struct doubleList{int data;doubleList *next;};void addfront(doubleList *&front, int data){doubleList *newNode = new doubleList{data, front};front = newNode;}bool contains(doubleList *&front, int num){int a = 0;for(doubleList *i = front; i != NULL; i = i->next){if(i->data==num){a == 1;}break;}if(a == 1){ return true;}if(a == 0){return false;}}int main(){doubleList *front = NULL;addfront(front, 102);

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 8 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
void traverse, void addFront

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture