好文档 - 专业文书写作范文服务资料分享网站

5~6次C语言上机作业

天下 分享 时间: 加入收藏 我要投稿 点赞

-------------------------------------------------------------------------------

-------------------------------------------------------------------------------

-------------------------------------------------------------------------------

#include #define N 9 void main() {

int itop,ibottom,iresearch,imiddle; int iA[N]={0,1,2,3,4,5,6,7,8}; scanf(\ itop=0;

ibottom=N-1;

while(itop<=ibottom) {

imiddle=(itop+ibottom)/2 ; if(iresearch

ibottom=imiddle-1;

else

if (iresearch>iA[imiddle])

itop=imiddle+1;

else{

printf(\元素%d在数组中, 下标是%d\\n, iresearch,imiddle\ return; } }

-------------------------------------------------------------------------------

-------------------------------------------------------------------------------

printf(\在数组中未找到\\n\ }

-------------------------------------------------------------------------------

5~6次C语言上机作业

---------------------------------------------------------------------------------------------------------------------------------------------------
推荐度:
点击下载文档文档为doc格式
7z8ml5rji98xzko02xoc4ddq3430jm00ycq
领取福利

微信扫码领取福利

微信扫码分享