自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(10)
  • 收藏
  • 关注

原创 哈夫曼树以及哈夫曼编码的实现

照搬教材的(#include <stdio.h>#include <stdlib.h>#include <limits.h>#include <string.h>typedef struct { unsigned int weight; unsigned int parent, lchild, rchild;} HTNode, *HuffmanTree;typedef char **HuffmanCode;unsigned

2020-12-06 15:40:24 182

原创 C++高精度整形数加减法模板

#include <bits/stdc++.h>using namespace std;void sum(string a, string b) { vector<int> ans = { 0 }; int dsz = a.size() - b.size(); for (int i = 0; i < dsz; ++i) //先将a不和b进行运算的部分添加 ans.push_back(a[i] - 48); for (int i = 0; i < b.s

2020-09-15 21:03:11 200

原创 二叉树层序遍历

目前实际效果为求每一层的平均值vector<double> averageOfLevels(TreeNode* root) { auto averages = vector<double>(); //不太清楚为什么都要这样新建容器.... auto q = queue<TreeNode*>(); //queue的特性为先进后出,可以实现当前层所有结点都处于同一队列中,用完就弹出 q.push(root); //根结点 while (!q.empty

2020-09-12 16:14:48 87

原创 第16章 模板与泛型编程

16.4template<typename itator, typename type>itator find(itator it, type f){ while (*it != f) it++; return it;}#include <iostream>#include <vector>#include <list>#include "head.h"using namespace std;int main() { vec

2020-08-12 17:45:13 120

原创 第14章 重载运算与类型转换

14.36#include <iostream>#include <string>#include <vector>using namespace std;class ScanfString {public: ScanfString(istream& in = cin) :is(in) {} string operator() () { getline(is, s); return s; } explicit operator

2020-08-12 17:40:42 89

原创 第13章 拷贝控制

13.26class HasPtr {public: HasPtr() = default; HasPtr(const string& s = string()) : ps(new string(s)), i(0) {} HasPtr(const HasPtr& p) : ps(new string(*p.ps)), i(p.i) {} HasPtr& operator=(const HasPtr& rhs){ auto newp = new str

2020-08-12 17:39:20 145

原创 第12章 动态内存

12.1.1#include<iostream>#include<fstream>#include<vector>#include<memory>#include<string>using namespace std;class StrBlob {public: typedef vector<string>::size_type size_type; StrBlob() : data(make_shared&l

2020-08-12 17:31:15 84

原创 第11章 关联容器

11.4#include<iostream>#include<fstream>#include<map>#include<set>#include<string>#include<iterator>#include<algorithm>using namespace std;int main(int argc, char* argv[]){ map<string, size_t> word

2020-08-12 17:25:14 91

原创 第10章 泛型算法

10.24#include<iostream>#include<vector>#include<list>#include<string>#include<iterator>#include<algorithm>#include<functional>using namespace std;using namespace std::placeholders;bool check_size(int n,

2020-08-12 17:19:00 93

原创 第9章 顺序容器

练习 9.51:#include <iostream>#include <string>using namespace std;struct date { unsigned long y; unsigned long m; unsigned long d; date(string s) { string::size_type pos; string::size_type pos2; pos = s.find_first_of(" /"); stri

2020-08-12 17:13:05 106

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除