双向链表
#include<stdio.h>#include<stdlib.h>typedef int ElemType; typedef struct node{ ElemType data; struct node *prev, *next; }Node; //初始化双向链表Node* initNode() { Node* head = (Node*)malloc(sizeof(Node)); head->data = 0; head->prev = NULL; head->next = NULL; return head;} //头插法int insertHead(Node* L, ElemType e) { Node* p = (Node*)malloc(sizeof(Node)); p->data = e; p->prev = L; p->next = L->next; if...
链表
#include<stdio.h>#include<stdlib.h>typedef int ElemType;typedef struct node { ElemType data; struct node* next;}Node; Node* initList() { Node* head = (Node*)malloc(sizeof(Node)); head->data = 0; head->next = NULL; return head;} //头插法int insertHead(Node* L, ElemType e)//L为头结点{ Node* p = (Node*)malloc(sizeof(Node)); p->data = e; p->next = L->next; L->next = p; return 1;} //遍历int listNode(Node* L)...
顺序表
#include<stdio.h>#include<stdlib.h>#define max 100typedef int ElemType; typedef struct { ElemType data; int length;}SeqList;//初始化SeqList initList(){ SeqList* L = (SeqList*)malloc(sizeof(SeqList)); L->data = (ElemType*)malloc(sizeof(ElemType) * max); L->length = 0; return L;} //在尾部添加数据int appendElem(SeqList* L, ElemType e) { if (L->length >= max) { printf(“顺序表已满”); return 0; } ...
时间复杂度
2的(t-1)次方 > n 是因为只有这时候循环结束(即这是判定条件)
面向对象
一.对象代表什么,就得封装对应的数据,并提供数据对应的行为比如“画圆”的对象是“圆”本身,因为画圆需要半径等等,并不是人画的再比如“关门”是门自己关的,人不过是给了个作用力 二.private(忘了的时候看一眼吧)直接用javabean插件就可以了嘻嘻当然也可以用快捷键 alt+insert 三.this这是成员变量和局部变量 此为就近原则,如果不加this,谁离age近值就是谁,加上this,则会调用成员变量