I think you’ve misunderstood the definition of median a bit.
The median is defined for any set of integers, irrespective of whether they are sorted or not. The median of \{1, 2, 3\}, \{2, 3, 1\}, \{3, 1, 2\} is all 2, because in each of those sets, 2 is the middle number if you write its elements in sorted order.
So, you don’t really need to print the numbers in sorted order.
t=int(input())
for _ in range(t):
x,y=map(int,input().split())
if ((3x)-y)%2==0:
f=t=((3x)-y)/2
else:
f=int(((3x)-y)/2)
t=(3x)-y-f
print(int(f),int(y),int(t))
Some test cases are not being able to pass :
here is the code:
int main() {
int t;
cin>>t;
while(t>0){
int x;
int y;
cin>>x>>y;
if(x<=100&&x>=-100&&y<=100&&y>=-100){
int a,b,c;
if(x==y){
a=x;
b=x;
c=x;;
cout<<a<<" “<<b<<” “<<c<<endl;
}
else if(y<0)
{
b=y;
c=0;
a=3x-b;
cout<<a<<" “<<b<<” "<<c<<endl;
}
else
{
a=0;
b=y;
c=3x-b;
cout<<a<<” “<<b<<” "<<c<<endl;
}
}
t–;
}
return 0;
}