Home > Back-end >  A great god for help
A great god for help

Time:10-03

The optimal storage problem code, but can change all say there is an error, is there a person to help change, thank you very much!

# include "stdio.h"
# define MAX 100
Void sort (float * a, int n)
{
int i,j;
Float temp;
for(i=0; i{
for(j=0; j{
If (a [j] & gt; A [m + 1])
{
Temp=a, [j].
A=\ [j + 1];
}
}
}
}
Void main ()
{
Int I, j, n, k;
Float a (MAX), x (MAX).
Float m=0, t=0;
Printf (" please input file number: \ n ");
The scanf (" % d ", & amp; n);
Printf (" please input the documents retrieval probability respectively: \ n ");
for(i=0; iThe scanf (" % f ", & amp; A [I]);
Sort (a, n);
K=(n - 1)/2;
X=[k] a [n - 1);
For (I=k + 1; iX=[I] a [n - 2 * (I - k)];
For (I=k - 1; I>=0; I -)
X=[I] a [n - 2 * (k - I) - 1);
for(i=0; i{
M +=a, [I].
For (j=I + 1; j[I] t +=x * x [j] * (j - I);
}
}
T=t/(m * m);
Printf (" after reasonable arrangements, to retrieve the least expect is: % f \ n ", t);
}

CodePudding user response:

One more}, give you blocked, compile without wrong
 

# include "stdio.h"
# define MAX 100
Void sort (float * a, int n)
{
int i,j;
Float temp;
for(i=0; i{
for(j=0; j{
If (a [j] & gt; A [m + 1])
{
Temp=a, [j].
A=\ [j + 1];
}
}
}
}
Void main ()
{
Int I, j, n, k;
Float a (MAX), x (MAX).
Float m=0, t=0;
Printf (" please input file number: \ n ");
The scanf (" % d ", & amp; n);
Printf (" please input the documents retrieval probability respectively: \ n ");
for(i=0; iThe scanf (" % f ", & amp; A [I]);
Sort (a, n);
K=(n - 1)/2;
X=[k] a [n - 1);
For (I=k + 1; iX=[I] a [n - 2 * (I - k)];
For (I=k - 1; I>=0; I -)
X=[I] a [n - 2 * (k - I) - 1);
for(i=0; i{
M +=a, [I].
For (j=I + 1; j[I] t +=x * x [j] * (j - I);
}
//}
T=t/(m * m);
Printf (" after reasonable arrangements, to retrieve the least expect is: % f \ n ", t);
}

CodePudding user response:

Compile ok, run error didn't check
# include "stdio.h"
# define MAX 100

Void sort (float * a, int n) {
int i, j;
Float temp;
For (I=0; I & lt; N - 1; I++) {
For (j=0; J & lt; N - 1-1; J++) {
If (a [j] & gt; + 1 a [j]) {
Temp=a, [j].
A=\ [j + 1];
}
}
}
}

Void main () {
Int I, j, n, k;
Float a (MAX), x (MAX).
Float m=0, t=0;
Printf (" please input file number: \ n ");
The scanf (" % d ", & amp; n);
Printf (" please input the documents retrieval probability respectively: \ n ");

For (I=0; I & lt; n; I++)
The scanf (" % f ", & amp; A [I]);

Sort (a, n);
K=(n - 1)/2;
X=[k] a [n - 1);

For (I=k + 1; I & lt; n; I++)
X=[I] a [n - 2 * (I - k)];

For (I=k - 1; I & gt;=0; I -)
X=[I] a [n - 2 * (k - I) - 1);

For (I=0; I & lt; n; I++) {
M +=a, [I].
For (j=I + 1; J & lt; n; J++)
[I] t +=x * x [j] * (j - I);
}

T=t/(m * m);
Printf (" after reasonable arrangements, to retrieve the least expect is: % f \ n ", t);
}

//}
  • Related