Input the sample 1:
The first line is the number of the second line with as some of the scores, space-delimited
6
80, 70, 60, 90, 79, 80
The output sample 1:
Calculates and returns the number of points higher than the corresponding position, the junction should be returned as new array, the output by the test procedure is complete,
,4,5,0,3,1 {1}
Higher than 80 points of 1:90, more than 70 points has four: 80,90,79,80... Is implicit illustrates its score ranking position... ,
Enter the sample 2:
5
80 80 80 90 88
The output sample 2:
Calculates and returns the number of points higher than the corresponding position, is the address at the beginning of a new array (dynamic application space), the output by the test procedure is complete,
,2,2,0,1 {2}
Function interface definition:
Int * fun (int * d, int N);
/* please fill in the answer here */
CodePudding user response:
Knock this is my code, but not time complexity, there is a test point time, how to improve??How to use a loop to complete??
int * fun (int * d, int N) {
int i,j;
Int * a=(int *) malloc (sizeof (int) * N);
for(i=0; ifor(j=0; j If (d [j] & gt; D [I])
A [I] + +;
}
return a;
}
CodePudding user response:
int m=6;
Int arr [] {80, 70, 60, 90, 79,};
Int result [101];
Memset (result, 0, sizeof (int) * 101);
for (int i=0; I & lt; 6; I++)
{
for (int j=0; J & lt; Arr [I]; J++)
The result [j] + +;
}
For (int m=0; M & lt; 6; M++)
Printf (" % d ", the result [arr [m]]).