My Code Has A Million An 1 Errors An IDK How To Make It Work..Plz Help/Finish
typedef int ElementType;
struct node
{
ElementType data;
node * next;
};
node first=null;
class LinkedList
{
public:
LinkedList();
bool empty(); // return true if the list is empty, otherwise return false
void InsertAtEnd(ElementType x);//insert a value x at the end
void Delete(ElementType x); //if value x is in the list, remove x
void Display();// Display the data values in the linked list
private:
node * first;//pointer to the first node in the list
};
#include "header.h"
#include<iostream>
using namespace std;
LinkedList::LinkedList(){
first = new node;
;}
void LinkedList::InsertAtEnd(ElementType x){
node *temp, *temp2;
temp=new node;
x=x;
temp->x;
temp->next = NULL;
if (first == NULL)
first = temp;
else
{ temp2 = first;
// We know this is not NULL - list not empty!
while (temp2->nxt != NULL)
{ temp2 = temp2->nxt;
// Move to next link in chain
}
temp2->nxt = temp;
LinkedList:isplay(){
temp = first;
do
{ if (temp == NULL)
cout << "End of list" << endl;
else
{ // Display details for what temp points to
cout << "Num : " << temp->num << endl;
cout << endl; // Blank line
// Move to next node (if present)
temp = temp->next;
}
}
while (temp != NULL);
}
int main()
{
LinkedList X;
for(int a = 1; a<10; a++)
if((a % 2) == 0)
X.InsertAtEnd(a);
X.Display();
X.Delete (2);
cout<<endl<<"list after deleting 2: "<<endl;
X.Display();
X.Delete(6);
cout<<endl<<"list after deleting 6: "<<endl;
X.Display()
If(!X.empty())
cout<<"List is not empty."<<endl;
return 0;
}
typedef int ElementType;
struct node
{
ElementType data;
node * next;
};
node first=null;
class LinkedList
{
public:
LinkedList();
bool empty(); // return true if the list is empty, otherwise return false
void InsertAtEnd(ElementType x);//insert a value x at the end
void Delete(ElementType x); //if value x is in the list, remove x
void Display();// Display the data values in the linked list
private:
node * first;//pointer to the first node in the list
};
#include "header.h"
#include<iostream>
using namespace std;
LinkedList::LinkedList(){
first = new node;
;}
void LinkedList::InsertAtEnd(ElementType x){
node *temp, *temp2;
temp=new node;
x=x;
temp->x;
temp->next = NULL;
if (first == NULL)
first = temp;
else
{ temp2 = first;
// We know this is not NULL - list not empty!
while (temp2->nxt != NULL)
{ temp2 = temp2->nxt;
// Move to next link in chain
}
temp2->nxt = temp;
LinkedList:isplay(){
temp = first;
do
{ if (temp == NULL)
cout << "End of list" << endl;
else
{ // Display details for what temp points to
cout << "Num : " << temp->num << endl;
cout << endl; // Blank line
// Move to next node (if present)
temp = temp->next;
}
}
while (temp != NULL);
}
int main()
{
LinkedList X;
for(int a = 1; a<10; a++)
if((a % 2) == 0)
X.InsertAtEnd(a);
X.Display();
X.Delete (2);
cout<<endl<<"list after deleting 2: "<<endl;
X.Display();
X.Delete(6);
cout<<endl<<"list after deleting 6: "<<endl;
X.Display()
If(!X.empty())
cout<<"List is not empty."<<endl;
return 0;
}