3 个数字的中位数:不使用数组或排序概念

Median of 3 Numbers: Without using Array or Sorting Concept

如何在不使用任何数组的情况下计算三个给定数字的中位数。我们可以通过简单的计算或比较来做到吗?

到目前为止我尝试了什么:

#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
  int a[3],i,n=3; 
  float m;
  clrscr();
  printf("Enter the elements:\n"); 
     for(i=0;i<n;i++) 
     { 
        scanf("%d",&a[i]); 
     } 
     if(n%2==0) 
     { 
       m=(a[n-1/2]+(a[n/2]))/2; 
     } 
     else 
     { 
       m=a[n/2]; 
     } 
     printf("\nMedian is %f",m); 
     getch(); 
}

首选代码语言:C,Java

中位数 是一个位于集合中间的数字,或者您可以将其视为集合中最中间的数字。所以为了找到它,我们将进行如下比较

median = max(min(a,b), min(max(a,b),c));
回答来自 Fastest way of finding the middle value of a triple?