-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlist.c
More file actions
58 lines (48 loc) · 1.15 KB
/
sqlist.c
File metadata and controls
58 lines (48 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
const MAXSIZE = 20;
enum returninfo {success, fail, overflow, underflow, range_error};
int dataarray[MAXSIZE];
int count; //节点个数及线性表长度
int *p = &dataarray
returninfo create(int num);
bool empty(void);
int length(void);
returninfo traverse(void);
returninfo get(int pos, int &item);
returninfo replace(int pos, const int &item);
returninfo insert(int pos, const int &item);
returninfo remove(void);
returninfo invertlist(void);
returninfo create(int num)
{
count = num;
printf("请依次输入数据(用空格隔开):\n", );
for(int i = 0; i < count; i++)
scanf("%d", &dataarray[i]);
return success;
}
bool empty(void)
{
if(count == 0)
return true;
else
return false;
}
returninfo traverse(void)
{
if(empty())
return underflow;
printf("遍历的数据依次为:\n");
for(int i = 0; i < count; i++)
printf("%d\n", dataarray[i]);
return success;
}
returninfo traverse(void)
{
if(empty())
return underflow;
printf("遍历的数据依次为:\n" );
for(int i = 0; i < count; i++)
printf("%d\n", *p(i));
return success;
}