Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
Lab021
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
DS Lab Group
实验项目模板
Lab021
提交
7e57b542
提交
7e57b542
8月 15, 2019
创建
作者:
宋海霞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify
上级
bc6a75fa
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
16 行删除
+14
-16
SeqTable.h
SeqTable.h
+6
-12
main.c
main.c
+8
-4
没有找到文件。
SeqTable.h
浏览文件 @
7e57b542
#ifndef SEQTABLE_H_
#define SEQTABLE_H_
//
// Include the C standard library header file here
//
#include <stdio.h>
//
// Other header files are included here
//
//
// Define the data structure here
//
// Elements in a linear table
typedef
int
KeyType
;
typedef
struct
ElemType
{
typedef
struct
ElemType
{
KeyType
key
;
// Primary key
// Omit other data and no longer define
}
ElemType
;
// The sequential storage structure of a linear table
typedef
struct
SeqTable
{
ElemType
*
elem
;
// Data element storage space base address, allocated according to the actual length when the table is built,
typedef
struct
SeqTable
{
ElemType
*
elem
;
// Data element storage space base address,
// allocated according to the actual length when the table is built,
// Unit 0 is left blank and is used from unit 1.
int
length
;
// The length of the table
}
SeqTable
;
...
...
@@ -43,12 +41,8 @@ int BinarySearch(SeqTable* pST, KeyType key);
void
InitSeqTable
(
SeqTable
*
pST
);
void
DeleteSeqTable
(
SeqTable
*
pST
);
//
// Declare global variables here
//
#endif
/* SEQTABLE_H_ */
main.c
浏览文件 @
7e57b542
#include "SeqTable.h"
int
main
(
int
argc
,
char
*
argv
[])
{
SeqTable
ST
;
// Linear table
...
...
@@ -59,17 +58,22 @@ function:
parameter:
pST -- Linear table pointer
*/
// 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
int
InitArray
[]
=
{
2
,
4
,
11
,
18
,
25
,
32
,
39
,
46
,
53
,
60
,
67
,
74
};
// The order must be from smallest to largest
// The order must be from smallest to largest
int
InitArray
[]
=
{
2
,
4
,
11
,
18
,
25
,
32
,
39
,
46
,
53
,
60
,
67
,
74
};
void
InitSeqTable
(
SeqTable
*
pST
)
{
int
i
;
pST
->
length
=
sizeof
(
InitArray
)
/
sizeof
(
InitArray
[
0
]);
pST
->
elem
=
(
ElemType
*
)
malloc
((
pST
->
length
+
1
)
*
sizeof
(
ElemType
));
// Because the 0 is left blank, the length must be increased by 1
// Because the 0 is left blank, the length must be increased by 1
pST
->
elem
=
(
ElemType
*
)
malloc
((
pST
->
length
+
1
)
*
sizeof
(
ElemType
));
for
(
i
=
1
;
i
<=
pST
->
length
;
i
++
)
for
(
i
=
1
;
i
<=
pST
->
length
;
i
++
)
{
pST
->
elem
[
i
].
key
=
InitArray
[
i
-
1
];
}
}
/*
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论