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


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


if (r!=NULL &#38&#38 (*pf)(s,r)==-1) s=r;
}
return r;
}
// 47--------------------------------------------------------


typedef int (*PCMP)(void*, void*);
struct xxx { void *data; xxx *next,*pred; };
void *F( xxx *p, PCMP pf)
{
xxx *q;
void *s;
if (p==NULL) return NULL;
q = p; s = p-&#62data;
do {
if ((*pf)(s,q-&#62data))==-1) s=q-&#62data;
q = q-&#62next;
} while (q != p);
return s;
}
// 48---------------------------------------------------------


typedef int (*PCMP)(void*, void*);
void F(void *p[], void PCMP pf)
{
int i,k;
do {
k=0;
for (i=1;p[i]!=NULL; i++)
if ((*pf)(p[i-1],p[i] &#62 0))
{ void *s = p[i-1];
p[i-1]=p[i];
p[i]=s; k++;
}
} while(k);
}
// 49---------------------------------------------------------


typedef int (*PCMP)(void*, void*);
void F(void *p[], void PCMP pf, void *q)
{ int i,j;
for (i=0; p[i]!=NULL &#38&#38 (*pf)(p[i],q) &#60 0; i++);
for (j=0; p[j]!=NULL; j++);
for (; j&#62=i; j--) p[j+1]=p[j];
p[i]=q;
}
// 50---------------------------------------------------------


typedef int (*PCMP)(void*, void*);
struct xxx { void *data; xxx *next; };
void F( xxx **p, PCMP pf, void *q)
{
xxx *s;
for (; *p!=NULL &#38&#38 (*pf)((*p)-&#62data,q) &#60 0; p = &#38(*p)-&#62next);
s = new xxx;
s-&#62data = q;
s-&#62next = (*p)-&#62next;
*p = s;
}
// ---------------------------------------------------------




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