ÈÃuserÊäÈë10¸öÕûÊý£¬´¢´æÔÚÒ»¸öarrayÀ È»ºó°Ñ×î´óµÄºÍ×îСµÄÊýÖµÌæ»»Î»Öà Àý×Ó£º Ten integers: 4, 6, -7, 3, -8, 2, 9, 18, -1, 0 The output: 4, 6, -7, 3, 18, 2, 9, -8, -1, 0 b]Çë¸ßÊÖ´ÓÐÂÊֵĽǶȸø³ö´ð°¸£¡[[/b]
ºÇºÇ ÎÒÒ²ÊÇÐÂÊÖ Â·¹ý ¿´¿´ÒýÓà package com; public class JiaoHuan { public static void getResult(int[] num) { int min=num[0]; int max=num[0]; int num1=0; int num2=0; for(int i=0;i<num.length;i++) { if(min>num[i]) ¡¡ 2Â¥Õý½â£¡ ¹ÛÍû``` Java code: public class Test { public static void main(String[] args) throws Exception { int[] arr = new int[]{4, 6, -7, 3, -8, 2, 9, 18, -1, 0}; testMethod(arr); for(int i = 0; i < arr.length; i++){ System.out.print(arr[i] + " "); } System.out.println(); } public static void testMethod(int[] arr){ int min = 0; int max = 0; for(int i = 1; i < arr.length; i++){ if(arr[min] > arr[i]){ min = i; } if(arr[max] < arr[i]){ max = i; } } arr[min] ^= arr[max]; arr[max] ^= arr[min]; arr[min]
ΪʲôHTMLÒÔ¼°Ò»Ð©ÆäËü±êÇ©»áÏÔÊ¾Ò»Ð©ÌØ¶¨±íÏÖÐÎÊ½ÄØ£¿ÈçHTMLÖеĻ»ÐбêÇ©<BR/>ÔڵײãÊÇÔõÑùʵÏÖµÄÄØ£¿ÏÖʵµÄÔÀíÊÇÊ²Ã´ÄØ È¥W3C¹Ù·½ÍøÕ¾ÉÏ£¬¿´¿´°É£¡ÎÒÏëÒ»¿´Äã¾ÍÃ÷°×ÁË ÎҲºͱàÒëÔÀíÓйأ¬ä¯ÀÀÆ÷Àï¿É ......