c语言动态非递减有序顺序表输入元素,插入元素使代码仍递增
时间: 2023-05-30 08:05:39
浏览: 68
下面是一个实现[动态](https://geek.csdn.net/educolumn/08aef4ab97997f5b9ed71860c44e8258?spm=1055.2569.3001.10083)非递减[有序](https://geek.csdn.net/educolumn/15fab50f7a8ae68f18ea897453a4e769?spm=1055.2569.3001.10083)顺序表输入元素,并插入元素使[代码](https://geek.csdn.net/educolumn/1572ef9b473b4e00f6b2bf6d428b7c27?spm=1055.2569.3001.10083)仍递增的示例[代码](https://geek.csdn.net/educolumn/1572ef9b473b4e00f6b2bf6d428b7c27?spm=1055.2569.3001.10083):
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int *data;
int length;
int capacity;
} SeqList;
void initList(SeqList *list, int capacity) {
list->data = (int *)malloc(sizeof(int) * capacity);
list->length = 0;
list->capacity = capacity;
void destroyList(SeqList *list) {
free(list->data);
list->data = NULL;
list->length = list->capacity = 0;
void displayList(SeqList list) {
for (int i = 0; i < list.length; i++) {
printf("%d ", list.data[i]);
printf("\n");
void [insert](https://geek.csdn.net/educolumn/54b8fe5f2aac0d59a4b7b189ca99a7bd?spm=1055.2569.3001.10083)(SeqList *list, int value) {
if (list->length == list->capacity) {
int *newData = (int *)reall
```