-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ2.c
More file actions
46 lines (41 loc) · 700 Bytes
/
Q2.c
File metadata and controls
46 lines (41 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<stdio.h>
/**
O(n^2) Implementation
*/
void solveCase()
{
int numWeights=0;
scanf("%d",&numWeights);
int A[numWeights][2];
int temp;
for(int i=0;i<numWeights;i++)
{
scanf("%d",&temp);
A[i][0]=temp;
A[i][1]=0;
if(i==0){ A[0][0] = temp;}
else{
for(int j=0;j<i;j++)
{
if(A[j][0]>temp)
++A[j][1];
}
}
}
for(int i=0;i<numWeights;i++)
{
printf("%d ",A[i][1]);
}
}
int main()
{
int cases ;
scanf("%d",&cases);
int numOfWeights ;
for(int i=1;i<=cases;i++)
{
solveCase();
printf("\n");
}
return 0;
}