标题:求高人解惑 输出时不显示结果
取消只看楼主
杨亚勤
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2010-1-29
结帖率:0
已结贴  问题点数:1 回复次数:0 
求高人解惑 输出时不显示结果
#include    <stdio.h >
#define     SIZE    16

int     binarysearch    ( int  low, int  high,    int    Array[],  int  value ) ;
        
int    main ( void )
{
        
        int  i = 0;
        int  location;
        int  array [ SIZE ];
        int  key;
        
        for( i=0; i< SIZE ; i++ )
        {
            
             array [ i ] = 2* i;
            
        }
        printf( " insert number you want to check\n ");
        scanf(" %d ", &key );  
        location = binarysearch  ( 0, SIZE-1, array, key );
      
        if ( !location )       printf(" no this one\n ");
        else
        {
             printf( "Location in the array is %d \n" , location );
        }
        return       0;
}


int     binarysearch    ( int  low, int  high,   int    Array[],   int  value )

{
         
        int   middle ;
        
        while  ( low <= high )
        {
               middle = (low + high)/2 ;
               if  ( value == Array [ middle ] )       return    middle;
               else  if ( value < Array [ middle ])  
               {
                     high = middle -1;
               }
               else  
               {
                    low = middle +1 ;
               }
               
        }
        
        return  0;
        
}







              
               
                    
搜索更多相关主题的帖子: void include number insert 
2012-02-03 00:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-360322-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.406056 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved