IIS 安装

下载
urlrewrite2.exe

配置web.config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
阅读全文 »

1
2
3
4
5
// 安装 npm-check-updates
npm install -g npm-check-updates
npm-check-updates // 运行检查
ncu -u // 更新package.json
npm install // 更新包到最新版

示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
PS E:\code\syxdevcode.github.io> npm install -g npm-check-updates
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
C:\Users\ponytest\AppData\Roaming\npm\npm-check-updates -> C:\Users\ponytest\AppData\Roaming\npm\node_modules\npm-check-updates\bin\cli.js
C:\Users\ponytest\AppData\Roaming\npm\ncu -> C:\Users\ponytest\AppData\Roaming\npm\node_modules\npm-check-updates\bin\cli.js
+ npm-check-updates@11.8.3
added 311 packages from 167 contributors in 641.613s
[====================] 13/13 100%
PS E:\code\syxdevcode.github.io> npm-check-updates
hexo ^5.3.0 → ^5.4.0 n
hexo-cli ^4.2.0 → ^4.3.0
hexo-deployer-git ^2.1.0 → ^3.0.0
hexo-generator-index ^1.0.0 → ^2.0.0
hexo-generator-searchdb ^1.3.3 → ^1.3.4
hexo-renderer-marked ^2.0.0 → ^4.1.0
hexo-renderer-stylus ^1.1.0 → ^2.0.1
hexo-server ^1.0.0 → ^2.0.0

Run ncu -u to upgrade package.json
PS E:\code\syxdevcode.github.io> ncu -u
[====================] 13/13 100%

hexo ^5.3.0 → ^5.4.0
hexo-cli ^4.2.0 → ^4.3.0
hexo-deployer-git ^2.1.0 → ^3.0.0
hexo-generator-index ^1.0.0 → ^2.0.0
hexo-generator-searchdb ^1.3.3 → ^1.3.4
hexo-renderer-marked ^2.0.0 → ^4.1.0
hexo-renderer-stylus ^1.1.0 → ^2.0.1
hexo-server ^1.0.0 → ^2.0.0

Run npm install to install new versions.

PS E:\code\syxdevcode.github.io> npm install
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: nice-napi@1.0.2 (node_modules\nice-napi):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for nice-napi@1.0.2: wanted {"os":"!win32","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 3 packages from 3 contributors, removed 52 packages, updated 10 packages and audited 287 packages in 13.589s

22 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities

参考:

nodejs包高效升级插件npm-check-updates

一个数组中只有一个数是唯一的,其他数都是成对出现,找出这个唯一的数

使用异或运算

时间复杂度为o(n),空间复杂度为o(1)

两个操作数的位中,相同则结果为0,不同则结果为1。

一个数和0异或还是自己,一个数和自己异或是0。

分析:由于位运算符异或运算的特点,即两个相同的数进行异或运算时,其结果为0,所以当将数组中所有的元素进行异或运算时,其结果必定为那个唯一的数。

1
2
3
4
5
6
7
8
9
static void FindNumber(int[] array)
{
int v = 0;
for (int i = 0; i < array.Length; i++)
{
v ^= array[i];
}
Console.WriteLine("只出现一次的数是:" + v);
}

HashSet方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
static void FindNumberHashSet(int[] array)
{
HashSet<int> set = new HashSet<int>();
List<int> list = new List<int>();

foreach (var t in array)
{
if(!set.Add(t))
list.Add(t);
}

foreach (var t in set)
{
if(!list.Exists(o => o == t))
Console.WriteLine("只出现一次的数是:" + t);
}
}

一个数组中有两个数是不同的,其他数都是成对出现,找出这两个不同的数

时间复杂度为o(n),空间复杂度为o(1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <fstream>
#include <iostream>
using namespace std;

int findFirstBit(int num)
{
int firstBit = 0;

while (((num & 1) == 0) && (firstBit < 8 * sizeof(int)))
{
num = num >> 1;
firstBit++;
}
return firstBit;
}

void findTwoDifNums(int arr[], int len, int &num1, int &num2)
{
int sum = 0;
for (int i = 0; i < len; i++)
{
sum ^= arr[i];
}

int firstBit = findFirstBit(sum);

for (int i = 0; i < len; i++)
{
int num = arr[i] >> firstBit;
if (num & 1)
{
num1 ^= arr[i];
}
else
{
num2 ^= arr[i];
}
}
}

int main()
{
int arr2[10] = {2, 3, 4, 9, 6, 4, 3, 9, 2, 8};

int num1 = 0;
int num2 = 0;

findTwoDifNums(arr2, sizeof(arr2) / sizeof(int), num1, num2);

cout << "The different two values is " << num1 << " " << num2 << endl;

getchar();

return 0;
}

参考:
找出数组中唯一不同的数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
public class HttpClientHelper
{
private static string zhongtaiUrl = ConfigurationManager.AppSettings["ZhongTaiUrl"];

/// <summary>
/// 用multipart/form-data发送
/// </summary>
/// <param name="postParaList"></param>
/// <returns></returns>
public static string PostMessage(List<PostDataClass> postParaList)
{
try
{
string responseContent = "";
var memStream = new MemoryStream();
var webRequest = (HttpWebRequest)WebRequest.Create(zhongtaiUrl);
// 边界符
var boundary = "---------------" + DateTime.Now.Ticks.ToString("X");
// 边界符
var beginBoundary = Encoding.ASCII.GetBytes("--" + boundary + "\r\n");
// 最后的结束符
var endBoundary = Encoding.ASCII.GetBytes("--" + boundary + "--\r\n");
memStream.Write(beginBoundary, 0, beginBoundary.Length);
// 设置属性
webRequest.Method = "POST";
webRequest.Timeout = 10000;
webRequest.ContentType = "multipart/form-data; boundary=" + boundary;
for (int i = 0; i < postParaList.Count; i++)
{
PostDataClass temp = postParaList[i];
// 写入字符串的Key
var stringKeyHeader = "Content-Disposition: form-data; name=\"{0}\"" +
"\r\n\r\n{1}\r\n";
var header = string.Format(stringKeyHeader, temp.Prop, temp.Value);
var headerbytes = Encoding.UTF8.GetBytes(header);
memStream.Write(headerbytes, 0, headerbytes.Length);

if (i != postParaList.Count - 1)
memStream.Write(beginBoundary, 0, beginBoundary.Length);
else
// 写入最后的结束边界符
memStream.Write(endBoundary, 0, endBoundary.Length);
}

byte[] b = memStream.ToArray();
string param = System.Text.Encoding.UTF8.GetString(b, 0, b.Length);
LogHelper.Info(string.Format("HttpClientHelper ==> PostMessage参数:{0}", param));

webRequest.ContentLength = memStream.Length;
var requestStream = webRequest.GetRequestStream();
memStream.Position = 0;
var tempBuffer = new byte[memStream.Length];
memStream.Read(tempBuffer, 0, tempBuffer.Length);
memStream.Close();
requestStream.Write(tempBuffer, 0, tempBuffer.Length);
requestStream.Close();
using (HttpWebResponse res = (HttpWebResponse)webRequest.GetResponse())
{
using (Stream resStream = res.GetResponseStream())
{
byte[] buffer = new byte[1024];
int read;
while ((read = resStream.Read(buffer, 0, buffer.Length)) > 0)
{
responseContent += Encoding.UTF8.GetString(buffer, 0, read);
}
}
res.Close();
}

LogHelper.Info(string.Format("HttpClientHelper ==> PostMessage返回值:{0}", responseContent));
return responseContent;
}
catch (Exception e)
{
LogHelper.Error(string.Format("HttpClientHelper ==> PostMessage方法======>Message:{0};StackTrace:{1};Source:{2};", e.Message, e.StackTrace, e.Source));
throw;
}
}
}

public class PostDataClass
{
public string Prop { get; set; }
public string Value { get; set; }
}

从文件读取流和向文件写入流,需要用到 C++ 中另一个标准库 fstream

  • ofstream :该数据类型表示输出文件流,用于创建文件并向文件写入信息。
  • ifstream :该数据类型表示输入文件流,用于从文件读取信息。
  • fstream :该数据类型通常表示文件流,且同时具有 ofstreamifstream 两种功能,这意味着它可以创建文件,向文件写入信息,从文件读取信息。
阅读全文 »

C++ 接口是使用抽象类来实现的。

如果类中至少有一个函数被声明为纯虚函数,则这个类就是抽象类纯虚函数是通过在声明中使用 = 0 来指定的,如下所示:

1
2
3
4
5
6
7
8
9
10
class Box
{
public:
// 纯虚函数
virtual double getVolume() = 0;
private:
double length; // 长度
double breadth; // 宽度
double height; // 高度
};

设计抽象类(通常称为 ABC)的目的,是为了给其他类提供一个可以继承的适当的基类。抽象类不能被用于实例化对象,它只能作为接口使用。如果试图实例化一个抽象类的对象,会导致编译错误。

因此,如果一个 ABC 的子类需要被实例化,则必须实现每个虚函数,这也意味着 C++ 支持使用 ABC 声明接口。如果没有在派生类中重写纯虚函数,就尝试实例化该类的对象,会导致编译错误。

可用于实例化对象的类被称为具体类

阅读全文 »

多态:有多个不同的类,都带有同一个名称但具有不同实现的函数,函数的参数甚至可以是相同的。

C++多态意味着调用成员函数时,会根据调用函数的对象的类型来执行不同的函数;

形成多态必须具备三个条件:

  • 1、必须存在继承关系;
  • 2、继承关系必须有同名虚函数(其中虚函数是在基类中使用关键字Virtual声明的函数,在派生类中重新定义基类中定义的虚函数时,会告诉编译器不要静态链接到该函数);
  • 3、存在基类类型的指针或者引用,通过该指针或引用调用虚函数;
阅读全文 »

C++ 允许在同一作用域中的某个函数和运算符指定多个定义,分别称为函数重载运算符重载

重载声明是指一个与之前已经在该作用域内声明过的函数或方法具有相同名称的声明,但是它们的参数列表和定义(实现)不相同。

当调用一个重载函数或重载运算符时,编译器通过把所使用的参数类型与定义中的参数类型进行比较,决定选用最合适的定义。选择最合适的重载函数或重载运算符的过程,称为重载决策

阅读全文 »

数据封装是面向对象编程的一个重要特点,它防止函数直接访问类类型的内部成员。类成员的访问限制是通过在类主体内部对各个区域标记 publicprivateprotected 来指定的。关键字 publicprivateprotected 称为访问修饰符。

一个类可以有多个 publicprotectedprivate 标记区域。每个标记区域在下一个标记区域开始之前或者在遇到类主体结束右括号之前都是有效的。

如果继承时不显示声明是 privateprotectedpublic 继承,则默认是 private 继承,在 struct 中默认 public 继承。

1
2
3
4
5
6
7
8
9
10
class Base {
public:
// 公有成员

protected:
// 受保护成员

private:
// 私有成员
};
阅读全文 »

面向对象程序设计中最重要的一个概念是继承。继承允许我们依据另一个类来定义一个类,这使得创建和维护一个应用程序变得更容易。这样做,也达到了重用代码功能和提高执行效率的效果。

当创建一个类时,不需要重新编写新的数据成员和成员函数,只需指定新建的类继承了一个已有的类的成员即可。这个已有的类称为基类,新建的类称为派生类

继承代表了 is a 关系。例如,哺乳动物是动物,狗是哺乳动物,因此,狗是动物,等等。

阅读全文 »
0%