#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");
}
原文:https://www.cnblogs.com/lifelessfaultless/p/9256560.html