FISHER ROSEMOUNT TL122正品 printf("%d\t", a[i]);
printf("\n請輸人所要查找的元素:");
scanf("%d",&val);
ret = binarySearch(a,8,val);
if(-1 == ret)
printf("查找失敗 \n");
else
printf ("查找成功 \n");
return 0;
}運(yùn)行結(jié)果:
-32 12 16 24 36 45 59 98
FISHER ROSEMOUNT TL122正品請輸入所要查找的元素:12
查找成功在上面的代碼中,我們成功地通過二分査找算法實(shí)現(xiàn)了查找功能,其實(shí)現(xiàn)過程如下圖所示。
二分査找算法的査找過程
FISHER ROSEMOUNT TL122正品在如上圖所示的查找過程中,先將序列中間位置的元素與所要査找的元素進(jìn)行比較,發(fā)現(xiàn)要査找的元素位干該位置的左部分序列中。接下來將mid的左邊一個(gè)元素作為 high,繼續(xù)進(jìn)行二分査找,這時(shí)mid所對應(yīng)的中間元素剛好是所要査找的元素,査找結(jié)束,返回査找元素所對應(yīng)的下標(biāo)。在main函數(shù)中通過返回值來判斷査找是否成功,如果査找成功。就打印輸出“査找成功”的信息,否則輸出“査找失畋”的信息。
廈門興銳達(dá)公司網(wǎng)址:http://www.xmxrdauto.com
FISHER ROSEMOUNT TL122
FISHER ROSEMOUNT 1151GP3E22B2
FISHER ROSEMOUNT 1151-DP5E12
FISHER ROSEMOUNT 1151DP4E12B1
FISHER ROSEMOUNT 1151AP8S52B1M3
FISHER ROSEMOUNT 10P5830-0001
FISHER ROSEMOUNT 1055-01-11-22
FISHER ROSEMOUNT 08712-0007-0002
FISHER ROSEMOUNT 04000-70/1/5/92
FISHER ROSEMOUNT 01984-2518-0002
KEYENCE KV-3000 KV-U7 KV-C64XC KV-C32TC KV-TF40 KV-L20V REAL TIME PLC
MITSUBISHI Q2AS CPU Q2ASCPU CPU UNIT
Watlow F4 F4DH-KKKA-01RG Ramping Temperature Controller
KEYENCE KV-1000, KV-C64XC, KV-B16XC, KV-C64TC PLC
Beckhoff CX1020 Embedded Controller CX1020-0122 Embedded PC System
OLYMPUS MX-50A-F MICROSCOPE VERTICAL ILLUMINATOR
Processor Interface Board for Tektronix TDS8000 Digital Sampling Oscilloscope
KEYENCE LK-2101 & LK-081 LASER CCD DISPLACEMENT CONTROLLER+SENS?OR+CABLE