943,600 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 425
  • C++ RSS
Nov 23rd, 2008
0

linked list pls pls help me

Expand Post »
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;
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
solimanmuttawa is offline Offline
3 posts
since Nov 2008
Nov 23rd, 2008
0

Re: linked list pls pls help me

What's a problem?..Detail please..
Reputation Points: 47
Solved Threads: 69
Posting Whiz
cikara21 is offline Offline
340 posts
since Jul 2008
Nov 23rd, 2008
0

Re: linked list pls pls help me

i cant write the following fuctions:
1)void AddElement_Front(struct Employee E)
2)void AddElement_End(struct Employee E)
3)void AddElement_Sorted(struct Employee E)
4)void DeleteFirst()
5)void DeleteLast()
6)struct Employee MinElement()
7)struct Employee MaxElement()
Reputation Points: 10
Solved Threads: 0
Newbie Poster
solimanmuttawa is offline Offline
3 posts
since Nov 2008
Nov 23rd, 2008
0

Re: linked list pls pls help me

In other words you want to cheat your teacher (and yourself)...
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: fstream problem..
Next Thread in C++ Forum Timeline: how to output integers with space!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC