首页 > 其他 > 详细

s_search.c

时间:2018-07-03 00:51:10      阅读:270      评论:0      收藏:0      [点我收藏+]
#include <stdio.h>
#include <stdlib.h>

int Data[20] = {1, 7, 9, 12, 15, 16, 20, 32, 35, 67, 78, 80, 83, 89, 90, 92, 97, 108, 120, 177};
int Counter = 1;

int Seq_Search(int Key)
{
    int i;

    for ( i = 0; i < 20; i++ )
    {
        printf("[%d]", Data[i]);
        if ( Key == Data[i] )
            return 1;
        Counter++;
    }
    return 0;
}

void main()
{
    int KeyValue;

    printf("Please enter your key value : ");
    scanf("%d", &KeyValue);

    if( Seq_Search(KeyValue))
        printf("\nSearch Time = %d\n", Counter);
    else
        printf("No Found!!\n");
}

  

s_search.c

原文:https://www.cnblogs.com/lifelessfaultless/p/9256560.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!