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


Тест 2 - часть 3



int F( xxx *p)
{ int n; xxx *q;
if (p==NULL) return(0);
for (q = p, p = p-&#62next, n=1; p !=q; p=p-&#62next, n++);
return(n);
}
// 19---------------------------------------------------------


struct xxx { int v; xxx *next,*pred; };
void F( xxx **p, int v)
{ xxx *q;
q = malloc(sizeof( xxx));
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;
}
}
// 20--------------------------------------------------------


struct xxx { int v; xxx *next; };
void F( xxx **ph)
{ xxx *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;
}
// 21--------------------------------------------------------


struct xxx { int v; xxx *next,*pred; };
xxx *F( xxx **pp, int n)
{ xxx *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);
}
// 22--------------------------------------------------------


struct xxx { int v; xxx *p[4]; };
int F(xxx *q)
{
int i,n,m;
if (q==NULL) return 0;
for (n=F1(q-&#62p[0]),i=1; i&#60 4; i++)
if ((m=F(q-&#62p[i])) &#62n) n=m;
return n+1;
}
// 23--------------------------------------------------------


struct xxx { int v; xxx *l,*r; };
int F( xxx *p)
{
if (p==NULL) return(0);
return (1 + F(p-&#62r) + F(p-&#62l));
}
// 24--------------------------------------------------------


struct xxx
{
int val,cnt;
xxx **link;
};
int F(xxx *p)
{ int i,n;
p-&#62cnt++;
for (i=0, n=1; p-&#62link[i] !=NULL; i++)
if (p-&#62link[i]-&#62cnt != p-&#62cnt)
n += F(p-&#62link[i]);
return (n);
}
// 25--------------------------------------------------------




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



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