查询(c语言实现)

 /*
* Describe:这是一个简单的查询程序
* Date: 2013/12/7
*/
#include <stdio.h>
#include <stdlib.h>
#define MAX 10 int main()
{
int i;
int n;
int array[MAX];
n = MAX; printf("请输入 %d 个数\n", n);
for (i = ; i < MAX; i++) {
printf("第 %d 个数 :", i + );
scanf("%d", &array[i]);
if (i == MAX - )
printf("already completed input!\n");
} while () {
int key;
printf("输入欲查找的数,并回车:\n");
scanf("%d", &key);
n = search(array, MAX, key);
printf("the number you entered locates in %d \n ", n);
}
return ;
} int search(int *array, int n, int key)
{ while (array[n - ] != key)
n--;
return n;
}
上一篇:vsftp搭建+虚拟用户


下一篇:Android Weekly Notes Issue #226