
Void Spisok::postroenie()
{
Man *t;
char ch='y';
t = phead;
int x=0;
while (ch!='n')
{
t->next = new Man;
t = t->next;
cout << "Введите фамилию и инициалы: " << endl;
cin.get();
cin.getline(t->name, l_name);
cout << "Введите год рождения: "<< endl;
cin >> t->birth_day;
cout << "Введите оклад: "<< endl;
cin >> t->pay;
t->next = NULL;
cout << "\nВвести следующий элемент списка?(y/n):";
cin >> ch;
}
}
-------------------------------------------------------------------------
Void Spisok::vyvod()
{
Man *t;
t = phead->next;
int i=1;
cout << endl;
cout << "SPISOK: ";
cout << endl;
while (t!=NULL)
{
cout << endl;
cout << i << " element: "<< endl;
cout << t->name << " "<< endl;
cout << t->birth_day << endl;
cout << t->pay << endl;
i++;
t = t->next;
}
cout << endl;
}
--------------------------------------------------------------------------
Void Spisok::ochistka()
{
Man *q,*q1;
q = phead;
q1 = q->next;
while (q1 != NULL)
{
q = q1;
q1 = q1->next;
delete q;
}
}
--------------------------------------------------------------------------
Man* Spisok::POISK (char* n, int bd, float p)
{
Man *t;
Res = NULL;
t = phead;
t = t->next;
while ( t!=NULL && Res==NULL )
{
if (strcmp(t->name, n)==0 && t->birth_day==bd && t->pay==p)
Res = t;
else
t = t->next;
}
return Res;
}
--------------------------------------------------------------------------
void Spisok::VSTAVKA (char* n1, int bd1, float p1)
{
Man *q;
q = new (Man);
strcpy(q->name, n1);
q->birth_day = bd1;
q->pay = p1;
q->next = Res->next;
Res->next= q;
}
-------------------------------------------------------------------------
void Spisok::VSTAVKA1 (char* n1, int bd1, float p1)
{
Man *q;
q = new (Man);
strcpy(q->name, Res->name);
q->birth_day = Res->birth_day;
q->pay = Res->pay;
q->next= Res->next;
strcpy(Res->name, n1);
Res->birth_day = bd1;
Res->pay = p1;
Res->next= q;
}
--------------------------------------------------------------------------
void Spisok::UDALENIE()
{
Man *q;
q = Res->next;
if (q!=NULL)
{
Res->next = Res->next->next; //(*(*Res).next).next
delete q;
}
else
cout<<"\nЗвено с заданным элементом - последнее!\n";
}
--------------------------------------------------------------------------
void Spisok::UDALENIE1()
{
Man *q,*q1,*q2;
q = Res->next;
if (q!=NULL)
{
strcpy(Res->name, q->name);
Res->birth_day = q->birth_day;
Res->pay = q->pay;
Res->next = q->next;
delete q;
}
else
{
q1 = phead;
q2 = q1->next;
while (q2!=Res)
{
q1 = q2;
q2 = q2->next;
}
q1->next = NULL;
q2 = NULL;
delete Res;
}
}