Информатика и технология программирования


Вопросы без ответов - часть 2


q-&#62next = *pp; *pp = q;
}
return tmp;
}
//------------------------------------------------------- 9


list *F9(list *pp, int n)
{ list *q;
for (q = pp; n!=0; q = q-&#62next, n--);
if (q-&#62next == q) { delete q; return NULL; }
if (q == pp) pp = q-&#62next;
q-&#62pred-&#62next = q-&#62next;
q-&#62next-&#62pred = q-&#62pred;
delete q;
return pp;
}
//------------------------------------------------------ 10


void F2(list **p, int v)
{ list *q;
q = new list;
q-&#62val = v; q-&#62next = *p; *p = q;
}
//------------------------------------------------------ 11


void F4(list **p, int v)
{ list *q;
q = new list;
for ( ; *p !=NULL; p = &#38(*p)-&#62next);
q-&#62val = v; q-&#62next = NULL; *p = q;
}
//------------------------------------------------------ 12


void F5(list **p, int n)
{ list *q;
for (; n!=0 &#38&#38 *p!=NULL; n--, p =&#38(*p)-&#62next);
q = *p;
if (*p != NULL) *p = (*p)-&#62next;
delete q;
}
//------------------------------------------------------ 13


void F7(list **p, int v)
{ list *q;
q = new list;
q-&#62val = v; q-&#62next = q-&#62pred = q;
if (*p == NULL) *p = q;
else
{
q-&#62next = *p; q-&#62pred = (*p)-&#62pred;
(*p)-&#62pred-&#62next = q; (*p)-&#62pred = q; *p=q;
}
}
//------------------------------------------------------ 14


void F8(list **ph)
{ list *q, *tmp, **pp;
tmp = NULL;
while (*ph !=NULL)
{
q = *ph; *ph = (*ph)-&#62next;
for (pp = &#38tmp; *pp !=NULL &#38&#38 (*pp)-&#62val &#60 q-&#62val;
pp = &#38(*pp)-&#62next);
q-&#62next = *pp; *pp = q;
}
*ph = tmp;
}
//------------------------------------------------------ 15


list *F9(list **pp, int n)
{ list *q;
for (q = *pp; n!=0; q = q-&#62next, n--);
if (q-&#62next == q) { *pp = NULL; return q; }
if (q == *pp) *pp = q-&#62next;
q-&#62pred-&#62next = q-&#62next;
q-&#62next-&#62pred = q-&#62pred;
return q;



Начало  Назад  Вперед



Книжный магазин