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-5  ส่วนของโปรแกรมหาตัวน้อยและตัวมากของตัวแปรสองตัว
 int min, max;
 if (a < b) {
   min = a;
   max = b;
 } else {
   min = b;
   max = a;
 }

int min = b; int max = a; if (a < b) { min = a; max = b; }
int min, max; if (a < b) { min = a; max = b; } if (a >= b) { min = b; max = a; }
©2009 S.Prasitjutrakul