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


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


else
v1[i1] = in[i0+i1], i1++;
v0[i0] = v1[i1] = MAXINT;
for (i0=i1=0; i0+i1 &#60 n; )
if (v0[i0] &#60 v1[i1])
in[i0+i1] = v0[i0], i0++;
else
in[i0+i1] = v1[i1], i1++;
}
}
//----------------------------------------------- ---7


void F7(int A[], int n)
{
int i,found;
do { found =0;
for (i=0; i&#60n-1; i++)
if (A[i] &#62 A[i+1])
{ int cc; cc = A[i]; A[i]=A[i+1]; A[i+1]=cc;
found++;
}
} while(found !=0);
}
//--------------------------------------- -----------8


void sort(int a[], int n)
{...любая сортировка одномерного массива... }
int A[100], B[10][10];
void F8()
{
int i,j;
for (i=0; i&#60 1 00; i++) B[i/10][i%10]=A[i];
for (i=0; i&#60 10; i++) sort(B[i],10);
for (i=0; i&#60 100; i++)
{
int k;
for (k=0, j=0; j&#60 10; j++)
if (B[j][0] &#60 B[k][0]) k=j;
A[i] = B[k][0];
for (j=1; j&#60 10; j++) B[k][j-1]=B[ k] [j];
B[k][9]=MAX_INT;
}
}
//--------------------------------------- -----------9


void F9(int in[], int a, int b)
{
int i,j,mode;
if (a &#62=b) return;
for (i=a, j=b, mode=1; i &#60 j; mode &#62 0 ? j-- : i++)
if (in[i] &#62 in[j])
{
int c;
c = in[i]; in[i] = in[j]; in[j]=c;
mode = -mode;
}
sort 10(in,a,i-1); sort 10(in,i+1,b);
}
//----------------------------------------------- ---10


void F10(int A[], int n)
{
int i,b,b1;
for (b=n-1; b!=0; b=b1)
{ b1=0;
for (i=0; i&#60b; i++)
if (A[i] &#62 A[i+1])
{ int cc; cc = A[i]; A[i]=A[i+1]; A[i+1]=cc;
b1=i;
}
}
}
//----------------------------------------------- ---11


void F11(int A[], int B1[], int B2[], int n)
{
int i,i1,i2,s,a1,a2,a,k;
for (s=1; s!=n; s*=2)
{
for (i=0; i&#60n/2; i++)
{ B1[i]=A[i]; B2[i]=A[i+n/2]; }
i1=i2=0; a1=a2=MAXINT;
for (i=0,k=0; i&#60n; i++)
{
if (a1==MAXINT &#38&#38 a2==MAXINT &#38&#38 i1==s &#38&#38 i2==s)
k+=s,i1=0,i2=0;
if (a1==MAXINT &#38&#38 i1!=s) a1=B1[k+i1],i1++;
if (a2==MAXINT &#38&#38 i2!=s) a2=B2[k+i2],i2++;
if (a1&#60a2)a=a1,a1=MAXINT;
else a=a2,a2=MAXINT;
A[i]=a;
}}}









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