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;
}
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.