/*顺序查找的基本运算与实现*/
来源:互联网 发布:linux查询java安装 编辑:程序博客网 时间:2024/05/02 02:41
/*顺序查找的基本运算与实现*/
#include <stdio.h>
#include <malloc.h>
typedef int keytype;
typedef struct
{
keytype num;
char name[10];
}datatype;
typedef struct
{
datatype *data;
int length;
}S_TBL;
int S_Search(S_TBL *tbl,keytype kx);
void main()
{
int i,flag;
keytype kx;
S_TBL *tbl=(S_TBL *)malloc(sizeof(S_TBL));
printf("please input table length:/n");
scanf("%d",&(tbl->length));
tbl->data=(datatype *)calloc( tbl->length, sizeof(datatype) );
printf("/nplease input element:/n");
for(i=1;i<=tbl->length;i++)
{
printf("please input num:/n");
scanf("%d",&((tbl->data[i]).num));
printf("please input name:/n");
scanf("%s",(tbl->data[i]).name);
}
printf("/nplease input a value that you want to find:/n");
scanf("%d",&kx);
flag=S_Search(tbl,kx);
if(flag==0)
{
printf("search failed!/n");
}
else
{
printf("num=%6d/tname=%s/n",tbl->data[flag].num,tbl->data[flag].name);
}
}
int S_Search(S_TBL *tbl,keytype kx)
{
int i;
tbl->data[0].num=kx;
for(i=tbl->length;tbl->data[i].num!=kx;i--)
{
;
}
return i;
}
- /*顺序查找的基本运算与实现*/
- 顺序栈基本运算的实现
- 实现顺序栈的各种基本运算的算法
- 队列的顺序存储结构及其基本运算的实现
- 队列的顺序存储结构及其基本运算的实现
- 顺序查找与二分查找的算法实现
- 实现顺序表各种基本运算的算法
- 实现顺序栈各种基本运算的算法
- 实现顺序队列各种基本运算的算法
- 实现顺序队列各种基本运算的算法
- 实现顺序串各种基本运算的算法
- 编写一个程序,实现顺序表的各种基本运算
- 编写一个程序,实现顺序栈的各种基本运算。
- 栈的顺序存储结构及其基本运算实现
- 栈的顺序存储结构及其基本运算实现
- 顺序队中实现队列的基本运算
- 栈的顺序存储结构及其基本运算实现
- 编写一个程序实现顺序串的各项基本运算
- SQL
- 新郎与新娘
- 委派任务
- win 7遇上的问题
- 学习技术的几个境界
- /*顺序查找的基本运算与实现*/
- HY57V561620FTP-H内存容量
- 状态
- 内存颗粒
- NAND FLASH与SDRAM对比
- 如何扩展ARM内存
- 学会忍耐
- 换位思考
- 下周开始实训