## 数据结构复习 原

E_C_Ares

ham4ectv/32dtgeb6vplmc4sebc9.e8c4/cd6a/o/40

M8/隐码

``````#define maxSize 100

typedef struct{
int data[maxSize];
int length;
}``````

``````typedef struct lNode{
int data;
struct lNode *next;
}lNode

lNode *list1 = (lNode*)malloc(sizeof(lNode));
free(list1);``````

dlNode

``````typedef struct dlNode{
int data;
struct dlNode *pri
struct dlNode *next
}``````

``````//查找等于E的位置
int findElem(sList L,int e){
int i;
for(i=0; i<L.length; ++i)
if(L.data[i] == e) return i;
return -1;
}

//插入e到 p
int insertElem(sList L, int p, int e){
int i;
if(p<0 || p>L.length || L.length == maxSize)  //不能插入后超长
return 0;

/*data属性变化*/
for(i = L.length - 1; i >= p; i--)
L.data[i+1] = L.data[i];
L.data[p] = e;

/*length属性变化*/
L.length ++;

return 1;
}

//reverse
void reverse(sList &L)  //L改变
{
int i, j;
int temp;
for(i=0, j=L.length-1; i<j; ++i, --j)
{
temp = L.data[i];
L.data[i] = L.data[j];
L.data[j] = temp;
}
}
``````

merge:

``````void sort_merge(lNode *A, lNode *B， lNode *&C) //为什么&？？
{
lNode *p = A -> next;
lNode *q = B -> next;
lNode *r;

C = A;
C -> next = NULL;

free(B);

r = C;
while(p != NULL && q != NULL)
{
if(p -> data <= q -> data){
r -> next = p;
p = p -> next;
r = r -> next;}
else{
r -> next = q;
q = q -> next;
r = r -> next;}
}
if (p!=NULL)
r -> next = p;
else if (q!=NULL)
r -> next = q;
else//有可能吗
r -> next = NULL;
}

void sort_demerge(lNode *A, lNode *B， lNode *&C) //为什么&？？
{
lNode *p = A -> next;
lNode *q = B -> next;
lNode *s;

C = A;
C -> next = NULL;

free(B);

while(p != NULL && q != NULL)
{
if(p -> data <= q -> data){
r = p;
p = p -> next;
r -> next = C -> next;
C -> next = r;
}
else{
r = q;
q = q -> next;
r -> next = C -> next;
C -> next = r;
}
}

while (p!=NULL){
r = p;
p = p -> next;
r -> next = C -> next;
C -> next = r;
}

while (q!=NULL)
{
r = p;
p = p -> next;
r -> next = C -> next;
C -> next = r;
}

}``````

``````//手加减
int stack[maxSize];
int top = -1;

stack[++top] = e;

e = stack[top--];``````

``````//括号匹配

int match_pair(char exp[], int n){

char stack[maxSize];
int top = -1;

int i;
for(i = 0; i < n; ++i)
{
if(exp[i] == '(')
stack[++top]='(';
if(exp[i] == ')')
if(top == -1) return 0;
else if(stack[top] = '(') top--;
else return 0;
}
if(top == -1) return 1;
else return 0;

}

//后缀算式四则运算
int get_value(int a, int b, char op){
switch(op){
case '+': return a+b; break;
case '-': return a-b; break;
case '*': return a*b; break;
case '/': if (b != 0) return a/b; else return 0; break;
}
}

int get_value(char exp[]){
int i, a, b, g;
int stack[maxSize];
int top = -1;

char op;
for...
//exp[x] - '0';
}
``````

``````lQ -> rear -> next = p;
lQ -> rear = p;

//p = lQ -> front; lQ -> front = p -> next; x = p -> data; free(p);
x = lQ -> front -> data;
lQ -> front = lQ -> front -> next;

``````

``````char str[] = "wa_na_ares,fav_de_spft."

//定长
typedef struct{
char str[maxSize + 1];
int length;
}string

//变长
typedef struct{
char *str;
int length;
}Str

if(Str.str){
free(Str.str);
Str.str = NULL
}

``````

``````#define maxSize 100

typedef struct{
int data[maxSize];
int length;
}``````

``````typedef struct lNode{
int data;
struct lNode *next;
}lNode

lNode *list1 = (lNode*)malloc(sizeof(lNode));
free(list1);``````

dlNode

``````typedef struct dlNode{
int data;
struct dlNode *pri
struct dlNode *next
}``````

``````int findElem(sList L,int e){
int i;
for(i=0; i<L.length; ++i)
``````

### E_C_Ares

PHP 源码阅读日记

2016/03/30
22
0

2016/01/02
115
0

20111564
2014/10/16
0
0

waikei
2015/09/18
4.4K
57

2014/03/05
163
4

EOS docker开发环境

3
0
《唐史原来超有趣》的读后感优秀范文3700字

《唐史原来超有趣》的读后感优秀范文3700字： 作者：花若离。我今天分享的内容《唐史原来超有趣》这本书的读后感，我将这本书看了一遍之后就束之高阁了，不过里面的内容一直在在脑海中回放，...

6
0

7
0
CompletableFuture get方法一直阻塞或抛出TimeoutException

xiaolyuh

5
0
dubbo 搭建与使用

7
0