| | |
linked list pls pls help me
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 3
Reputation:
Solved Threads: 0
i am done with the main of the program but i have difficulty with several functions that need help if u please help me thank u very much
#include <iostream>
#include <string>
using namespace std;
void Output(struct Employee *data_ptr);
void Input(struct Employee *data_ptr);
void AddElement_Front(struct Employee E);
void AddElement_End(struct Employee E);
void AddElement_Sorted(struct Employee E);
void DeleteFirst();
void DeleteLast();
void DeleteElement(int ID);
int ListCount();
int ListSize();
void PrintList();
void SortList();
struct Employee MinElement();
struct Employee MaxElement();
struct Employee
{
int id_number;
int age;
float salary;
string name;
struct Employee* next;
};
struct Employee *head = NULL;
void main()
{
int Operation = 1;
cout<<"Press 1 to add element to the front of the list"<<endl;
cout<<"Press 2 to add element to the end of the list"<<endl;
cout<<"Press 3 to add element in sorting order of the list"<<endl;
cout<<"Press 4 to delete the first element from the list"<<endl;
cout<<"Press 5 to delete the last element from the list"<<endl;
cout<<"Press 6 to delete a given element from the list"<<endl;
cout<<"Press 7 to print the list"<<endl;
cout<<"Press 8 to count the number of elements in the list"<<endl;
cout<<"Press 9 to calculate the size of the list"<<endl;
cout<<"Press 10 to sort the list"<<endl;
cout<<"Press 11 to find the minimum element in the list"<<endl;
cout<<"Press 12 to find the maximum element in the list"<<endl;
cout<<"Press -1 to exit"<<endl;
while(Operation != -1)
{
cout<<"\nChoose Operation : ";
cin>>Operation;
struct Employee Element;
switch(Operation)
{
case 1 :
Input(&Element);
AddElement_Front(Element);
break;
case 2 :
Input(&Element);
AddElement_End(Element);
break;
case 3 :
Input(&Element);
AddElement_Sorted(Element);
break;
case 4:
DeleteFirst();
break;
case 5:
DeleteLast();
break;
case 6:
int ID;
cout<<"Enter the ID of the employee you want to delete : ";
cin>>ID;
DeleteElement(iD);
break;
case 7:
PrintList();
break;
case 8:
int N;
N=ListCount();
cout<<"The number of elements in the list is : "<<N<<endl;
break;
case 9:
int S;
S=ListSize();
cout<<"The size of the list is : "<<S<<" bytes"<<endl;
break;
case 10:
SortList();
PrintList();
break;
case 11:
Element = MinElement();
cout<<"The Employee with minimum ID : "<<endl;
Output(&Element);
break;
case 12:
Element = MaxElement();
cout<<"The Employee with maximum ID : "<<endl;
Output(&Element);
break;
}
}
}
void Output(struct Employee *data_ptr)
{
cout<<"******************************\n";
cout<<"ID = "<<data_ptr->id_number<<endl;
cout<<"Name = "<<data_ptr->name<<endl;
cout<<"Age = "<<data_ptr->age<<endl;
cout<<"Salary = "<<data_ptr->salary<<endl;
cout<<"******************************\n";
}
void Input(struct Employee *data_ptr)
{
cout<<"******************************\n";
cout<<"Enter ID : ";
cin>>data_ptr->id_number;
cout<<"Enter Name : ";
cin>>data_ptr->name;
cout<<"Enter Age : ";
cin>>data_ptr->age;
cout<<"Enter Salary : ";
cin>>data_ptr->salary;
cout<<"******************************\n";
}
void AddElement_Front(struct Employee E)
{
//Fill in the code
}
void AddElement_End(struct Employee E)
{
//Fill in the code
}
void AddElement_Sorted(struct Employee E)
{
//Fill in the code
}
void DeleteFirst()
{
//Fill in the code
}
void DeleteLast()
{
//Fill in the code
}
void DeleteElement(int ID)
{
//Fill in the code
}
void PrintList()
{
//Fill in the code
}
int ListCount()
{
int N;
//Fill in the code
return N;
}
int ListSize()
{
int S;
int Count = ListCount();
S=Count * sizeof(struct Employee);
return S;
}
void SortList()
{
//Fill in the code
}
struct Employee MinElement()
{
struct Employee min;
//Fill in the code
return min;
}
struct Employee MaxElement()
{
struct Employee max;
//Fill in the code
return max;
}
#include <iostream>
#include <string>
using namespace std;
void Output(struct Employee *data_ptr);
void Input(struct Employee *data_ptr);
void AddElement_Front(struct Employee E);
void AddElement_End(struct Employee E);
void AddElement_Sorted(struct Employee E);
void DeleteFirst();
void DeleteLast();
void DeleteElement(int ID);
int ListCount();
int ListSize();
void PrintList();
void SortList();
struct Employee MinElement();
struct Employee MaxElement();
struct Employee
{
int id_number;
int age;
float salary;
string name;
struct Employee* next;
};
struct Employee *head = NULL;
void main()
{
int Operation = 1;
cout<<"Press 1 to add element to the front of the list"<<endl;
cout<<"Press 2 to add element to the end of the list"<<endl;
cout<<"Press 3 to add element in sorting order of the list"<<endl;
cout<<"Press 4 to delete the first element from the list"<<endl;
cout<<"Press 5 to delete the last element from the list"<<endl;
cout<<"Press 6 to delete a given element from the list"<<endl;
cout<<"Press 7 to print the list"<<endl;
cout<<"Press 8 to count the number of elements in the list"<<endl;
cout<<"Press 9 to calculate the size of the list"<<endl;
cout<<"Press 10 to sort the list"<<endl;
cout<<"Press 11 to find the minimum element in the list"<<endl;
cout<<"Press 12 to find the maximum element in the list"<<endl;
cout<<"Press -1 to exit"<<endl;
while(Operation != -1)
{
cout<<"\nChoose Operation : ";
cin>>Operation;
struct Employee Element;
switch(Operation)
{
case 1 :
Input(&Element);
AddElement_Front(Element);
break;
case 2 :
Input(&Element);
AddElement_End(Element);
break;
case 3 :
Input(&Element);
AddElement_Sorted(Element);
break;
case 4:
DeleteFirst();
break;
case 5:
DeleteLast();
break;
case 6:
int ID;
cout<<"Enter the ID of the employee you want to delete : ";
cin>>ID;
DeleteElement(iD);
break;
case 7:
PrintList();
break;
case 8:
int N;
N=ListCount();
cout<<"The number of elements in the list is : "<<N<<endl;
break;
case 9:
int S;
S=ListSize();
cout<<"The size of the list is : "<<S<<" bytes"<<endl;
break;
case 10:
SortList();
PrintList();
break;
case 11:
Element = MinElement();
cout<<"The Employee with minimum ID : "<<endl;
Output(&Element);
break;
case 12:
Element = MaxElement();
cout<<"The Employee with maximum ID : "<<endl;
Output(&Element);
break;
}
}
}
void Output(struct Employee *data_ptr)
{
cout<<"******************************\n";
cout<<"ID = "<<data_ptr->id_number<<endl;
cout<<"Name = "<<data_ptr->name<<endl;
cout<<"Age = "<<data_ptr->age<<endl;
cout<<"Salary = "<<data_ptr->salary<<endl;
cout<<"******************************\n";
}
void Input(struct Employee *data_ptr)
{
cout<<"******************************\n";
cout<<"Enter ID : ";
cin>>data_ptr->id_number;
cout<<"Enter Name : ";
cin>>data_ptr->name;
cout<<"Enter Age : ";
cin>>data_ptr->age;
cout<<"Enter Salary : ";
cin>>data_ptr->salary;
cout<<"******************************\n";
}
void AddElement_Front(struct Employee E)
{
//Fill in the code
}
void AddElement_End(struct Employee E)
{
//Fill in the code
}
void AddElement_Sorted(struct Employee E)
{
//Fill in the code
}
void DeleteFirst()
{
//Fill in the code
}
void DeleteLast()
{
//Fill in the code
}
void DeleteElement(int ID)
{
//Fill in the code
}
void PrintList()
{
//Fill in the code
}
int ListCount()
{
int N;
//Fill in the code
return N;
}
int ListSize()
{
int S;
int Count = ListCount();
S=Count * sizeof(struct Employee);
return S;
}
void SortList()
{
//Fill in the code
}
struct Employee MinElement()
{
struct Employee min;
//Fill in the code
return min;
}
struct Employee MaxElement()
{
struct Employee max;
//Fill in the code
return max;
}
![]() |
Similar Threads
- What's the difference?(linked list) (C)
- trouble with linked list (C)
- Deleting In Linked List.. (C++)
- Inserting in a sorted linked list(sorted alphabetically) (C++)
- The C++ LINKED LIST (C++)
- To create contact manager using doubly linked list(c++) (C++)
- How to read in a sentence and insert in to linked list? (C++)
- help by sorting a simply linked list (C)
Other Threads in the C++ Forum
- Previous Thread: fstream problem..
- Next Thread: how to output integers with space!
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






