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


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


F(p-&#62l, pf);
}
//------------------------------------------------------- 9


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


void F(void ***p, int (*pf)(void*))
{
int i,j;
for (i =0; p[i] != NULL; i++)
for (j =0; p[i][j] != NULL; j++)
if ((*pf)(p[i][j])) return p[i][j];
return NULL;
}
//------------------------------------------------------ 11


void F(void ***p, void (*pf)(void*))
{
int i,j;
for (i =0; p[i] != NULL; i++)
for (j =0; p[i][j] != NULL; j++) (*pf)(p[i][j]);
}
//------------------------------------------------------- 12


typedef int (*PCMP)(void*, void*);
void F(void **p, PCMP pf, void *q)
{ int n,i;
for (n=0; p[n]!=NULL; n++)
if ((*pf)(q,p[n]) ==1) break;
for (i=n; p[i] !=NULL; i++);
for (; i &#62 n; i--) p[i+1]=p[i];
p[n]=q;
}
//------------------------------------------------------ 13


typedef int (*PCMP)(void*, void*);
void *F(void *p[], PCMP pf, void *q)
{ int h,l,m;
for (h=0, p[h]!=NULL; h++);
for (h--, l=0; l &#60=h;)
{
m = (h+l)/2;
switch ((*pf)(q, p[m]))
{
case 0: return(p[m]);
case -1: h = m-1; break;
case 1: l = m+1; break;
}
}
return(NULL);
}
//---------------------------------- --------------------- 14


typedef int (*PTEST)(void*);
void *F(void *p, int sz, int n, PTEST pf)
{ char *q;
for (q=p; n!=0; q +=sz, n--)
if ((*pf)(q)) return(q);
return(NULL);
}
//------------------------------------------------------- 15


typedef int (*PCMP)(void*, void*);
struct xxx { void *data; xxx *next; };
void *F( xxx **p, PCMP pf)
{
xxx *q;
void *s;
for (s=p[0]-&#62data; *p != NULL; p++)
for (q = *p; q != NULL; q = q-&#62next)
if ((*pf)(s,q-&#62data)==-1) s=q-&#62data;
return s;
}
//------------------------------------------------------ 16


typedef int (*PCMP)(void*, void*);
struct xxx { void *data; xxx *next; };
struct sxxx { xxx *ph; sxxx *next; };



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



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