當前位置:首頁 » 編程語言 » c語言mid

c語言mid

發布時間: 2025-05-03 20:13:15

❶ C語言程序編寫——折半查找法

#include<stdio.h>
intmain()
{inta[16]={15,14,13,12,11,10,9,8,7,6,5,4,3,1,0};
intl=0,r=15,mid,x;
scanf("%d",&x);
do
{mid=(l+r)/2;
if(a[mid]==x)break;
if(x>a[mid])r=mid-1;
elsel=mid+1;
}while(l<=r);
if(a[mid]==x)
printf("a[%d]=%d ",mid,x);
else
printf("無此數 ");
return0;
}

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:648
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:939
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:634
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:823
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:734
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1069
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:302
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:163
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:855
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:765