-
Notifications
You must be signed in to change notification settings - Fork 0
/
5.8_test.c
94 lines (92 loc) · 2.43 KB
/
5.8_test.c
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
#include "5.8_Sqlist.h"
void menu(void)
{
printf("***************************************************************************************\n");
printf("************** <线性表的顺序存储> **************\n");
printf("************** 1.创建一个线性表 **************\n");
printf("************** 2.销毁线性表 **************\n");
printf("************** 3.清空线性表 **************\n");
printf("************** 4.判断线性表是否为空 **************\n");
printf("************** 5.获取线性表某一置元素的值 **************\n");
printf("************** 6.获取单前线性表的长度 **************\n");
printf("************** 7.打印线性表 **************\n");
printf("************** 8.插入一个元素 **************\n");
printf("************** 9.删除一个元素 **************\n");
printf("************** 0.退出 **************\n");
printf("***************************************************************************************\n");
}
int main(void)
{
Sqlist L;
int choose = 0;
int n = 0;
Init_Sq(&L);
do
{
menu();
printf("请输入对应的数字选择相应的功能:>");
scanf("%d", &choose);
switch (choose)
{
case 1:
printf("请输入要插入的元素个数:>");
scanf("%d", &n);
Create_Sq(&L, n);
break;
case 2:
Destroy_Sq(&L);
break;
case 3:
Clear_Sq(&L);
break;
case 4:
IsEmpty_Sq(&L);
break;
case 5:
GetElem_Sq(&L);
break;
case 6:
GetLength_Sq(&L);
break;
case 7:
Print_Sq(&L);
break;
case 8:
Insert_Sq(&L);
break;
case 9:
Delete_Sq_Elem(&L);
break;
case 0:
printf("退出成功\n");
break;
default:
printf("请输入正确的数字\n");
break;
}
} while (choose);
return 0;
}
//int main(void)
//{
// int i = 0;
// int* a;
// a = (int*)malloc(10 * sizeof(int));
// if (a == NULL)
// {
// printf("空间分配失败\n");
// }
//
// for (i = 0; i < 10; i++)
// {
// a[i] = i;
// }
//
// for (i = 0; i < 10; i++)
// {
// printf("%d ", a[i]);
// }
//
// return 0;
//}