4. เลือกปฏิบัติ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 4-19  ส่วนของโปรแกรมหาค่ามัธยฐานของ a, b, และ c
  int median;
  if ((b<=a) && (a<=c)) median = a;       // b <= a <= c
  else if ((c<=a) && (a<=b)) median = a;  // c <= a <= a  
  else if ((a<=b) && (b<=c)) median = b;  // a <= b <= c
  else if ((c<=b) && (b<=a)) median = b;  // c <= a <= b
  else median = c;         // a <= c <= b หรือ  b <= c <= a
©2009 S.Prasitjutrakul