正文
目录会跟随阅读位置移动。
阅读进度

这份文档按“定义—结论—规律—易错点—题型应用—代码模板”整理,你直接拿去背、拿去刷题、拿去套上机题,直接拉满。
一个完整的计算机系统由两大部分组成:
满足:
典型:
典型:
只允许在表的一端进行插入和删除操作的线性表。
递归依赖栈实现,因为每次调用都要保存现场,返回时再按相反顺序恢复。
只允许在一端插入、另一端删除的线性表。
将顺序队列首尾相连,形成环状结构。
2^(i-1) 个结点2^k - 1 个结点若:
则:
i = n/2 开始向前处理包括:
_shapecount1MyName2a-countconstgo 不是关键字unsigned 是关键字charshortintlongfloatdoubleboolunsigned 不能修饰 float+ - * / %> < >= <= == !=&& || !++ --若:
int a = 8;
则:
a && (a-1) 为真a > (a-1) 为真a < (a-1) 为假按书写顺序执行。
if(条件) 语句1;
else 语句2;
switch(表达式){
case 常量: 语句; break;
default: 语句;
}
for(初始化; 条件; 变化){ 循环体; }
while(条件){ 循环体; }
do{ 循环体; }while(条件);
int a[5];
int a[5] = {1,3,5,7,9};
则:
a[2] = 5a[3] = 7int *p;
int *p = a;
则:
*p == a[0]*(p+2) == a[2]int **b;
*b 是一级指针**b 是最终数据int *p = new int;
int *a = new int[10];
delete p;
delete[] a;
new char[strlen(p)+1]
多出的1是给 \0。
int x = 100;
int &r = x;
* 改实参构成条件:
void fun(int a, int b = 7, char *p = "**");
inlineclass MyClass{
private:
int x;
public:
void setX(int a);
};
特点:
~类名void print() const;
ClassName(const ClassName &obj);
调用场景:
class Derived : public Base{
};
Derived(int i) : Base(i), n(i) {}
构造:
析构相反。
virtual void foo();
作用:
virtual float GetArea() = 0;
特点:
.::.*->*?:=[]()->c1 + c2 等价于 c1.operator+(c2)
int& operator[](int index){
return data[index];
}
template<typename T>
T add(T a, T b){
return a + b;
}
template<typename T1, typename T2>
class Test{
public:
void foo(T2 t);
};
typename 和 class 通常等价template<typename T1, typename T2>
void Test<T1, T2>::foo(T2 t){
}
cin:标准输入cout:标准输出cerr:标准错误输出clog:带缓冲错误输出ifstreamofstreamfstreamios::inios::outios::appios::binaryios::truncios::appsetw(n):设置宽度,通常只影响下一次输出setfill(ch):设置填充字符left/right:左对齐/右对齐fixed:定点输出setprecision(n):配合 fixed 时保留 n 位小数类名::char* 和 char[] 类型不匹配closed == true 表示门关着!closedclass Shape{
public:
virtual float GetArea() = 0;
virtual float GetPerim() = 0;
};
class Circle : public Shape{
private:
float r;
public:
Circle(float radius) : r(radius) {}
float GetArea(){ return 3.14f * r * r; }
float GetPerim(){ return 2 * 3.14f * r; }
};
class Rectangle : public Shape{
private:
float len, width;
public:
Rectangle(float l, float w) : len(l), width(w) {}
float GetArea(){ return len * width; }
float GetPerim(){ return 2 * (len + width); }
};
Shape *sp;
sp = new Circle(5);
cout << sp->GetArea() << endl;
delete sp;
sp = new Rectangle(4, 6);
cout << sp->GetArea() << endl;
delete sp;
class CDeepCopy{
private:
int *p;
int n;
public:
CDeepCopy(int k){
n = k;
p = new int[n];
}
CDeepCopy(const CDeepCopy& r){
n = r.n;
p = new int[n];
for(int i = 0; i < n; i++)
p[i] = r.p[i];
}
CDeepCopy& operator=(const CDeepCopy& r){
if(this != &r){
delete[] p;
n = r.n;
p = new int[n];
for(int i = 0; i < n; i++)
p[i] = r.p[i];
}
return *this;
}
~CDeepCopy(){
delete[] p;
}
};
for(int j = i; j < counter - 1; ++j)
elem[j] = elem[j+1];
--counter;
--i;
void filter(){
for(int i = 0; i < counter; ++i){
if(elem[i] < 0){
for(int j = i; j < counter - 1; ++j)
elem[j] = elem[j+1];
--counter;
--i;
}
}
}
int& operator[](int index){
return data[index];
}
if(i < m_Len)
return data[i];
else
return 0;
Person p = ps[m];
ps[m] = ps[i];
ps[i] = p;
2^(i-1) 个结点。go 不是关键字。unsigned 不能修饰 float。this。[]、=、()、-> 常考成员函数重载。typename 和 class 通常等价。cin 是标准输入。cout 是标准输出。ios::app 表示追加。setw() 一般只影响下一次输出。fixed + setprecision(3) 表示保留3位小数。strlen + 1。new[] 对应 delete[]。class Shape{
public:
virtual float GetArea() = 0;
virtual float GetPerim() = 0;
};
ClassName(const ClassName& r){
n = r.n;
p = new int[n];
for(int i = 0; i < n; i++)
p[i] = r.p[i];
}
ClassName& operator=(const ClassName& r){
if(this != &r){
delete[] p;
n = r.n;
p = new int[n];
for(int i = 0; i < n; i++)
p[i] = r.p[i];
}
return *this;
}
for(int j = i; j < count - 1; ++j)
a[j] = a[j+1];
count--;
i--;
T& operator[](int index){
return data[index];
}
Derived(int i) : Base(i), n(i) {}
Base *p = new Derived();
p->foo();
delete p;
ofstream fout("a.txt", ios::app);
类名::=0new[] 后用错 delete--ipulished by jokerbai