- 博客(19)
- 收藏
- 关注
原创 C++类与对象(构建函数,析构函数,拷贝构建函数)
#include<iostream> using namespace std; //定义类 class cname { public : //构造函数声明 cname(int q, int w, int e); //复制构造函数声明 cname(cname& r); //析构函数 ~
2020-09-09 16:07:51
190
原创 链栈C++实现
#include<iostream> #include <cstdio> using namespace std; typedef struct LNode { char data; struct LNode* next; }LNode; typedef struct { LNode* top; int counter; }Link_Stack; int push(Link_Stack*& S, char q); int pop(Link_Stack*& S, int
2020-08-12 16:11:57
284
原创 python微博批量爬取图片
import requests import json from bs4 import BeautifulSoup from urllib.request import urlretrieve #构造函数 def sk(): #请求头 header={ 'user-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4
2020-07-22 14:16:57
566
原创 笔记(一)内联函数和C++类和对象
一.内联函数(inline): 1.目的:减少开销 2.用法:建立函数时前面加上inline,调用时正常用即可 例如: inline int go (Que &d) { tree S; S=d,a[d.rear]; d.rear++; return 0; } 3.注意事项: (1)内联函数不能出现switch (2)使用前必须声明 (3)对内联函数不能进行异常接口声明 二.类和对象(class) 格式写法: class name/*类名*/ { public :
2020-06-27 22:05:18
222
原创 进制转换 和 位运算
十进制转化为二进制 例如十进制数’155’转化为二进制数: 常规操作是把155连续除以2取余倒置相加,但有时十进制数过大除2操作过多 改进:先把10进制数依次除16转化为16进制数 155%16=B 9%16=9 所得16进制数为B9:拆分B=11=8021=1011 9=8001=1001 倒置为10011011 位运算 按位与’&‘ 0和1为0,1和1为1,0和0为0 按位或’|‘ 0和1为1,1和1为1,0和0为0 ...
2020-06-27 21:25:12
1209
原创 哈希表构建 冲突处理开地址法 线性探测
#include <stdio.h> #define maxsize 50 typedef struct { int key; int status; }pi;/*成员:key关键字 status状态*/ typedef struct { pi a[maxsize]; int length; }list; int enter(list& L); int init(list&am...
2020-05-06 19:47:03
204
原创 线性表折半查找 递归和非递归
#include <stdio.h> #include <malloc.h> typedef struct { int* a; int length; }ST; int seek_2(ST S, int low, int high); int init(ST& S); int seek(ST S); int key,mid; //全局变量 int main() {...
2020-04-27 19:35:05
394
原创 无向图邻接矩阵
#include <stdio.h> #include <stdlib.h> #define maxsize 50 typedef struct { char v[maxsize]; int arcs[maxsize][maxsize]; int node, side; }Adjacent; int init(Adjacent& T); int print(Adja...
2020-04-25 19:00:23
710
原创 哈夫曼树
#include <stdio.h> #include <malloc.h> typedef struct { int weight; int par; int Lc; int Rc; }node, *HFtree; typedef struct Link { int data; int sub; struct Link* next; } Link, * LinkList;...
2020-04-12 17:30:29
229
原创 二叉树建立 递归先序遍历 非递归先序遍历
#include <stdio.h> #include <malloc.h> typedef struct Bitree{char data;Bitree *Lc;Bitree *Rc;}Bitree,*Bitnode; //二叉树数据类型 typedef struct stack {Bitnode root;struct stack *next;}stack,*Lin...
2020-04-05 17:39:09
978
原创 数据结构稀疏矩阵三元组 压缩存储 转置
#include <stdio.h> #define maxsize 1000 typedef struct {int z; int x; int y;}A; typedef struct {A data[maxsize]; int h; int l; int e;}Ternary; int init (Ternary &b); int enter (Ternary &...
2020-03-28 17:14:26
599
原创 数据结构 队列
顺序队列 #include <stdio.h> #include <stdlib.h> #include <malloc.h> #define max 5 typedef struct { int a[max];int front ;int rear;}que; int init(que &d); int come (que &d,int j);...
2020-03-22 10:23:25
110
原创 链栈
#include <stdio.h> #include <malloc.h> typedef struct stack {int data;struct stack *next;}stack,*Linkstack; int push (Linkstack &s,int a); int pop (Linkstack &s,int &t); void i...
2020-03-14 13:49:23
119
原创 数据结构 顺序栈
栈:先进后出 定义栈类型 typedef struct {int *top;int *base;int c;}stack; //栈顶指针top 栈底指针 base 主函数 int main () { int a,*b,i;int t,c; stack s; init (s); scanf ("%d",&t); for (i=0;i<t;i++) ...
2020-03-14 13:41:41
130
原创 单链表排序
单链表排序 思路: 从首元结点开始依次与后面比较一轮确定第一个位置,再从第二个位置 依次与后面比较确定第二个位置,以此类推 ```int sort (LinkList &L) { LinkList a,b; a=a->next; //首元结点// int t; for(a=L->next;a->next!=NULL;a=a->next) { ...
2020-03-09 18:36:36
110
原创 数据结构之单链表操作代码实现
单链表及实现操作 全局变量的定义和函数调用声明 #include <stdio.h> #include <malloc.h> #include <stdlib.h> #define Ok 1 #define Error 0 typedef int Elemtype; typedef struct LNode { Elemtype data;struct LNod...
2020-03-02 19:16:04
329
原创 数据结构 线性表顺序结构 代码实现
线性表顺序结构及相应操作 #include <stdio.h> #include <stdlib.h> #define maxsize 10 //数据类型定义// typedef struct {int elem[maxsize];int length;}sqlist; typedef int status; //函数调用声明// void init (sqlist *L...
2020-02-29 16:10:15
347
原创 关于*L 和 *&L的区别理解
★ 相同点: 1. 都是地址的概念; 指针指向一块内存,它的内容是所指内存的地址;引用是某块内存的别名。 ★ 区别: 1. 指针是一个实体,而引用仅是个别名; 2. 引用使用时无需解引用(*),指针需要解引用; 3. 引用只能在定义时被初始化一次,之后不可变;指针可变; 引用“从一而终” 4. 引用没有 const,指针有 const,const 的指针不可变; 5. 引用不能为空,指针可以为空; 6. “sizeof 引用”得到的是所指向的变量(对象)的大小,而“sizeof 指针”得到的是指针本身(所指
2020-02-29 11:22:23
4502
6
原创 使用函数输出指定范围内的完数
习题6-3 使用函数输出指定范围内的完数 (20分) 本题要求实现一个计算整数因子和的简单函数,并利用其实现另一个函数,输出两正整数mm和nn(0<m\le n\le 100000<m≤n≤10000)之间的所有完数。所谓完数就是该数恰好等于除自身外的因子之和。例如:6=1+2+3,其中1、2、3为6的因子。 函数接口定义: int factorsum( int number );...
2020-02-25 16:01:36
1839
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅