-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
143 lines (109 loc) · 76.3 KB
/
index.html
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><meta><title>Hexo</title><link rel="manifest" href="/manifest.json"><meta name="application-name" content="Hexo"><meta name="msapplication-TileImage" content="/img/favicon.svg"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-title" content="Hexo"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta property="og:type" content="blog"><meta property="og:title" content="Hexo"><meta property="og:url" content="http://example.com/"><meta property="og:site_name" content="Hexo"><meta property="og:locale" content="en_US"><meta property="og:image" content="http://example.com/img/og_image.png"><meta property="article:author" content="John Doe"><meta property="twitter:card" content="summary"><meta property="twitter:image" content="/img/og_image.png"><script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","mainEntityOfPage":{"@type":"WebPage","@id":"http://example.com"},"headline":"Hexo","image":["http://example.com/img/og_image.png"],"author":{"@type":"Person","name":"John Doe"},"description":""}</script><link rel="icon" href="/img/favicon.svg"><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/styles/atom-one-light.css"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;600&family=Source+Code+Pro"><link rel="stylesheet" href="/css/default.css"><style>body>.footer,body>.navbar,body>.section{opacity:0}</style><!--!--><!--!--><!--!--><!--!--><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/build/cookieconsent.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/lightgallery.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/justifiedGallery.min.css"><!--!--><!--!--><script src="https://cdn.jsdelivr.net/npm/[email protected]/pace.min.js"></script><!--!--><!--!--><meta name="generator" content="Hexo 5.2.0"></head><body class="is-2-column"><nav class="navbar navbar-main"><div class="container"><div class="navbar-brand justify-content-center"><a class="navbar-item navbar-logo" href="/"><img src="/img/logo.svg" alt="Hexo" height="28"></a></div><div class="navbar-menu"><div class="navbar-start"><a class="navbar-item is-active" href="/">Home</a><a class="navbar-item" href="/archives">Archives</a><a class="navbar-item" href="/categories">Categories</a><a class="navbar-item" href="/tags">Tags</a><a class="navbar-item" href="/about">About</a></div><div class="navbar-end"><a class="navbar-item search" title="Search" href="javascript:;"><i class="fas fa-search"></i></a></div></div></div></nav><section class="section"><div class="container"><div class="columns"><div class="column order-2 column-main is-8-tablet is-8-desktop is-8-widescreen"><div class="card"><article class="card-content article" role="article"><div class="article-meta is-size-7 is-uppercase level is-mobile"><div class="level-left"><span class="level-item">Posted <time dateTime="2020-11-23T01:08:16.288Z" title="2020-11-23T01:08:16.288Z">2020-11-23</time></span><span class="level-item">Updated <time dateTime="2020-11-23T02:52:01.129Z" title="2020-11-23T02:52:01.129Z">2020-11-23</time></span><span class="level-item"><a class="link-muted" href="/categories/R/">R</a></span><span class="level-item">3 minutes read (About 470 words)</span></div></div><h1 class="title is-3 is-size-4-mobile"><a class="link-muted" href="/2020/11/23/Using-R-to-Calculating-the-Distance/"> </a></h1><div class="content"><h3 id="Using-R-to-Measure-Distance"><a href="#Using-R-to-Measure-Distance" class="headerlink" title="Using R to Measure Distance"></a>Using R to Measure Distance</h3><h4 id="1-question-description"><a href="#1-question-description" class="headerlink" title="1.question description:"></a><strong>1.question description:</strong></h4><p>using R code to calculate the distance, such as “euclidean” “chebyshev” “cosine” </p>
<h4 id="2-solutions"><a href="#2-solutions" class="headerlink" title="2.solutions :"></a><strong>2.solutions :</strong></h4><p>using the key words “R package” and “distance” searching for the packages, and<br>we got the package of <code>philentropy</code></p>
<h4 id="2-1-code"><a href="#2-1-code" class="headerlink" title="2.1.code :"></a><strong>2.1.code :</strong></h4><p>#install package in console<br><code> install.packages("philentropy")</code><br>#load the package<br><code>library(philentropy)</code><br>#define the vectors needed calculating<br><code>v1 <- (1,3,4)</code><br><code>v2 <- (2,3,2)</code><br>#calculate with the default parameters<br>#manhattan distance,euclidean,cosine,lin.cor(pearson)<br><code>distance(x, method = "manhattan")</code><br><code>distance(x, method = "euclidean")</code></p>
<h4 id="2-2-output"><a href="#2-2-output" class="headerlink" title="2.2.output :"></a><strong>2.2.output :</strong></h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">Metric: 'manhattan'; comparing: 2 vectors.</span><br><span class="line">manhattan </span><br><span class="line"> 3 </span><br><span class="line">> distance(x, method = "euclidean")</span><br><span class="line">Metric: 'euclidean'; comparing: 2 vectors.</span><br><span class="line">euclidean </span><br><span class="line"> 2.236068 </span><br><span class="line">> distance(x, method = "chebyshev")</span><br><span class="line">Metric: 'chebyshev'; comparing: 2 vectors.</span><br><span class="line">chebyshev </span><br><span class="line"> 2 </span><br><span class="line">> distance(x, method = "cosine")</span><br><span class="line">Metric: 'cosine'; comparing: 2 vectors.</span><br><span class="line"> cosine </span><br><span class="line">0.9037378 </span><br><span class="line">> lin.cor(A,B)</span><br><span class="line"> pearson </span><br><span class="line">0.1889822 </span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h4 id="3-supplyment-materials"><a href="#3-supplyment-materials" class="headerlink" title="3.supplyment materials:"></a><strong>3.supplyment materials:</strong></h4><p>the difference between different type of distance </p>
<h5 id="3-1-euclidean"><a href="#3-1-euclidean" class="headerlink" title="3.1. euclidean"></a><strong>3.1. <code>euclidean</code></strong></h5><p><a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Euclidean_distance" title="Euclidean_distance">https://en.wikipedia.org/wiki/Euclidean_distance</a></p>
<p>In mathematics, the Euclidean distance between two points in Euclidean space is a number, the length of a line segment between the two points. It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, and is occasionally called the Pythagorean distance.</p>
<h5 id="3-2-cosine-distance"><a href="#3-2-cosine-distance" class="headerlink" title="3.2. cosine distance"></a><strong>3.2. <code>cosine distance</code></strong></h5><p>cosine distance (or cosine similarity, angular cosine distance, angular cosine similarity) between two variables.<br><a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Cosine_similarity" title="cosine distance">https://en.wikipedia.org/wiki/Cosine_similarity</a></p>
<p>Cosine similarity is a measure of similarity between two non-zero vectors of an inner product space. It is defined to equal the cosine of the angle between them, which is also the same as the inner product of the same vectors normalized to both have length 1. The cosine of 0° is 1, and it is less than 1 for any angle in the interval (0, π] radians. It is thus a judgment of orientation and not magnitude: two vectors with the same orientation have a cosine similarity of 1, two vectors oriented at 90° relative to each other have a similarity of 0, and two vectors diametrically opposed have a similarity of -1, independent of their magnitude. The cosine similarity is particularly used in positive space, where the outcome is neatly bounded in {\displaystyle [0,1]}[0,1]. </p>
<h5 id="3-3-cosine-distance"><a href="#3-3-cosine-distance" class="headerlink" title="3.3. cosine distance"></a><strong>3.3. <code>cosine distance</code></strong></h5><p><a target="_blank" rel="noopener" href="https://medium.com/swlh/is-correlation-distance-a-metric-5a383973978f#:~:text=Correlation%20distance%20is%20a%20popular,as%20d%3D1%2Dr." title="cosine distance">https://medium.com/swlh/is-correlation-distance-a-metric-5a383973978f#:~:text=Correlation%20distance%20is%20a%20popular,as%20d%3D1%2Dr.</a></p>
<p>Correlation distance is a popular way of measuring the distance between two random variables with finite variances¹. If the correlation² between two random variables is r, then their correlation distance is defined as d=1-r. However, a proper distance measure needs to have a few properties, i.e. should be a metric, and it is not trivial whether correlation distance has these properties. In this note, we ask whether correlation distance is a metric or not.</p>
</div></article></div><div class="card"><article class="card-content article" role="article"><div class="article-meta is-size-7 is-uppercase level is-mobile"><div class="level-left"><span class="level-item">Posted <time dateTime="2020-10-10T03:25:33.000Z" title="2020-10-10T03:25:33.000Z">2020-10-10</time></span><span class="level-item">Updated <time dateTime="2020-10-11T01:04:49.007Z" title="2020-10-11T01:04:49.007Z">2020-10-11</time></span><span class="level-item"><a class="link-muted" href="/categories/Data-Structure/">Data Structure</a><span> / </span><a class="link-muted" href="/categories/Data-Structure/C/">C</a></span><span class="level-item">2 minutes read (About 264 words)</span></div></div><h1 class="title is-3 is-size-4-mobile"><a class="link-muted" href="/2020/10/10/DS-1-1-Recursion/">DS_1_1_Recursion</a></h1><div class="content"><h3 id="数据结构-chapter-1-1-1-递归(recursion)"><a href="#数据结构-chapter-1-1-1-递归(recursion)" class="headerlink" title="数据结构_chapter 1_1.1_递归(recursion)"></a>数据结构_chapter 1_1.1_递归(recursion)</h3><h5 id="1-递归实现阶乘"><a href="#1-递归实现阶乘" class="headerlink" title="1. 递归实现阶乘"></a>1. 递归实现阶乘</h5><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">double</span> <span class="title">factorial</span><span class="params">(<span class="keyword">unsigned</span> <span class="keyword">int</span> number)</span> <span class="comment">//数据类型 double 可用于阶乘运算较宽数值范围乘积的存储</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">if</span>(number<=<span class="number">0</span>){ <span class="comment">//此处应修改为: number<=1 ,若为 number<=0, 则会重复一次乘1操作 </span></span><br><span class="line"> <span class="keyword">return</span> <span class="number">1</span>;</span><br><span class="line"> } </span><br><span class="line"> <span class="keyword">return</span> number*factorial(number<span class="number">-1</span>);</span><br><span class="line"> } </span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">unsigned</span> <span class="keyword">int</span> number;</span><br><span class="line"> <span class="built_in">scanf</span>(<span class="string">"%d"</span>,&number);</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d的阶乘结果为:%f\n"</span>,number,factorial(number));</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>; </span><br><span class="line"> } </span><br></pre></td></tr></table></figure>
<h5 id="2-递归实现斐波那契数列前-‘n’-项输出"><a href="#2-递归实现斐波那契数列前-‘n’-项输出" class="headerlink" title="2. 递归实现斐波那契数列前 ‘n’ 项输出"></a>2. 递归实现斐波那契数列前 ‘n’ 项输出</h5><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">fibonaci</span><span class="params">(<span class="keyword">int</span> i)</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">if</span>(i==<span class="number">1</span>) <span class="comment">//数列第一项</span></span><br><span class="line"> {</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>; </span><br><span class="line"> } </span><br><span class="line"> <span class="keyword">if</span>(i==<span class="number">2</span>) <span class="comment">//数列第二项</span></span><br><span class="line"> {</span><br><span class="line"> <span class="keyword">return</span> <span class="number">1</span>; </span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> fibonaci(i<span class="number">-1</span>) + fibonaci(i<span class="number">-2</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> number,i;</span><br><span class="line"> <span class="built_in">scanf</span>(<span class="string">"%d"</span>,&number);</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">1</span>;i<=number;i++)</span><br><span class="line"> {</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d\t\n"</span>,fibonaci(i));</span><br><span class="line"> } </span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h5 id="3-递归实现从’1-n’整型数据顺序输出"><a href="#3-递归实现从’1-n’整型数据顺序输出" class="headerlink" title="3. 递归实现从’1~n’整型数据顺序输出"></a>3. 递归实现从’1~n’整型数据顺序输出</h5><p>非递归方法:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">PrintN</span><span class="params">(<span class="keyword">int</span> N)</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> i;</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">1</span>;i<=N;i++)</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d\n"</span>,i);</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> N;</span><br><span class="line"> <span class="built_in">scanf</span>(<span class="string">"%d"</span>,&N);</span><br><span class="line"> PrintN(N);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>递归方法:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">PrintN</span><span class="params">(<span class="keyword">int</span> N)</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">if</span>(N><span class="number">0</span>){</span><br><span class="line"> PrintN(N<span class="number">-1</span>);</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d\n"</span>,N);</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> N;</span><br><span class="line"> <span class="built_in">scanf</span>(<span class="string">"%d"</span>,&N);</span><br><span class="line"> PrintN(N);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>or</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">PrintN</span><span class="params">(<span class="keyword">int</span> N)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> N;</span><br><span class="line"> <span class="built_in">scanf</span>(<span class="string">"%d"</span>,&N);</span><br><span class="line"> PrintN(N);</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line">}</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">PrintN</span><span class="params">(<span class="keyword">int</span> N)</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">if</span>(N><span class="number">0</span>){</span><br><span class="line"> PrintN(N<span class="number">-1</span>);</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d\n"</span>,N);</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br></pre></td></tr></table></figure>
</div></article></div><div class="card"><article class="card-content article" role="article"><div class="article-meta is-size-7 is-uppercase level is-mobile"><div class="level-left"><span class="level-item">Posted <time dateTime="2020-10-08T05:02:36.000Z" title="2020-10-08T05:02:36.000Z">2020-10-08</time></span><span class="level-item">Updated <time dateTime="2020-10-08T05:05:50.692Z" title="2020-10-08T05:05:50.692Z">2020-10-08</time></span><span class="level-item"><a class="link-muted" href="/categories/Programming/">Programming</a><span> / </span><a class="link-muted" href="/categories/Programming/C/">C</a></span><span class="level-item">2 minutes read (About 345 words)</span></div></div><h1 class="title is-3 is-size-4-mobile"><a class="link-muted" href="/2020/10/08/6-array-data-processing-2/">6_array_data_processing_2</a></h1><div class="content"><h3 id="6-数组处理批量数据"><a href="#6-数组处理批量数据" class="headerlink" title="6.数组处理批量数据"></a>6.数组处理批量数据</h3><h6 id="6-4-将整型数组元素行列位置对调"><a href="#6-4-将整型数组元素行列位置对调" class="headerlink" title="6.4 将整型数组元素行列位置对调"></a>6.4 将整型数组元素行列位置对调</h6><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> a[<span class="number">2</span>][<span class="number">3</span>]={{<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>},{<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>}};</span><br><span class="line"> <span class="keyword">int</span> b[<span class="number">3</span>][<span class="number">2</span>],i,j;</span><br><span class="line"> </span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"array a:\n"</span>);</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<=<span class="number">1</span>;i++) <span class="comment">//遍历二维数组a 元素并赋值于b;遍历行 </span></span><br><span class="line"> {</span><br><span class="line"> <span class="keyword">for</span> (j=<span class="number">0</span>;j<=<span class="number">2</span>;j++) <span class="comment">//遍历数组a 列 </span></span><br><span class="line"> {</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%5d"</span>,a[i][j]);</span><br><span class="line"> b[j][i]=a[i][j]; <span class="comment">//数组a中元素与数组b中 元素对调(行、列) </span></span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"array b:\n"</span>);</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<=<span class="number">2</span>;i++) <span class="comment">//遍历数组b,循环结构for遍历行 </span></span><br><span class="line"> {</span><br><span class="line"> <span class="keyword">for</span>(j=<span class="number">0</span>;j<=<span class="number">1</span>;j++) <span class="comment">//遍历列 </span></span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%5d"</span>,b[i][j]);</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h6 id="6-5-将整型数组中最大值元素及相应行列位置输出"><a href="#6-5-将整型数组中最大值元素及相应行列位置输出" class="headerlink" title="6.5 将整型数组中最大值元素及相应行列位置输出"></a>6.5 将整型数组中最大值元素及相应行列位置输出</h6><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> i,j,row=<span class="number">0</span>,colum=<span class="number">0</span>,max;</span><br><span class="line"> <span class="keyword">int</span> a[<span class="number">3</span>][<span class="number">4</span>]={{<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>},{<span class="number">9</span>,<span class="number">8</span>,<span class="number">7</span>,<span class="number">6</span>},{<span class="number">-10</span>,<span class="number">10</span>,<span class="number">-5</span>,<span class="number">2</span>}};</span><br><span class="line"> max=a[<span class="number">0</span>][<span class="number">0</span>];</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<=<span class="number">2</span>;i++) <span class="comment">//数组遍历,行遍历 </span></span><br><span class="line"> <span class="keyword">for</span>(j=<span class="number">0</span>;j<=<span class="number">3</span>;j++) <span class="comment">// 数组遍历,列遍历 </span></span><br><span class="line"> <span class="keyword">if</span>(a[i][j]>max) <span class="comment">//“打擂台”算法 </span></span><br><span class="line"> {max=a[i][j];</span><br><span class="line"> row=i;</span><br><span class="line"> colum=j;</span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"max=%d\nrow=%d\ncolum=%d\n"</span>,max,row,colum); <span class="comment">//最大值输出、行/列号输出 </span></span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line"> } </span><br></pre></td></tr></table></figure>
<h6 id="6-6-字符数组输出特定字符"><a href="#6-6-字符数组输出特定字符" class="headerlink" title="6.6 字符数组输出特定字符"></a>6.6 字符数组输出特定字符</h6><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">char</span> c[<span class="number">15</span>]={<span class="string">'I'</span>,<span class="string">' '</span>,<span class="string">'a'</span>,<span class="string">'m'</span>,<span class="string">' '</span>,<span class="string">'a'</span>,<span class="string">' '</span>,<span class="string">'s'</span>,<span class="string">'t'</span>,<span class="string">'u'</span>,<span class="string">'d'</span>,<span class="string">'e'</span>,<span class="string">'n'</span>,<span class="string">'t'</span>,<span class="string">'.'</span>};</span><br><span class="line"> <span class="keyword">int</span> i;</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<<span class="number">15</span>;i++)</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%c"</span>,c[i]);</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line"> } </span><br></pre></td></tr></table></figure>
<h6 id="6-7-用星号(-)输出钻石图案"><a href="#6-7-用星号(-)输出钻石图案" class="headerlink" title="6.7 用星号(*)输出钻石图案"></a>6.7 用星号(*)输出钻石图案</h6><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">char</span> diamond[][<span class="number">5</span>]={{<span class="string">' '</span>,<span class="string">' '</span>,<span class="string">'*'</span>},{<span class="string">' '</span>,<span class="string">'*'</span>,<span class="string">' '</span>,<span class="string">'*'</span>,<span class="string">' '</span>},{<span class="string">'*'</span>,<span class="string">' '</span>,<span class="string">' '</span>,<span class="string">' '</span>,<span class="string">'*'</span>},{<span class="string">' '</span>,<span class="string">'*'</span>,<span class="string">' '</span>,<span class="string">'*'</span>,<span class="string">' '</span>},{<span class="string">' '</span>,<span class="string">' '</span>,<span class="string">'*'</span>,<span class="string">' '</span>,<span class="string">' '</span>}}; <span class="comment">//定义字符数组元素初始值,5行5列 </span></span><br><span class="line"> <span class="keyword">int</span> i,j;</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<<span class="number">5</span>;i++) <span class="comment">//遍历数组元素,行遍历 </span></span><br><span class="line"> {</span><br><span class="line"> <span class="keyword">for</span>(j=<span class="number">0</span>;j<<span class="number">5</span>;j++) <span class="comment">//遍历数组元素,列遍历 </span></span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%c"</span>,diamond[i][j]);</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
</div></article></div><div class="card"><article class="card-content article" role="article"><div class="article-meta is-size-7 is-uppercase level is-mobile"><div class="level-left"><span class="level-item">Posted <time dateTime="2020-10-07T14:28:02.000Z" title="2020-10-07T14:28:02.000Z">2020-10-07</time></span><span class="level-item">Updated <time dateTime="2020-10-08T00:43:09.789Z" title="2020-10-08T00:43:09.789Z">2020-10-08</time></span><span class="level-item"><a class="link-muted" href="/categories/Programming/">Programming</a><span> / </span><a class="link-muted" href="/categories/Programming/C/">C</a></span><span class="level-item">2 minutes read (About 338 words)</span></div></div><h1 class="title is-3 is-size-4-mobile"><a class="link-muted" href="/2020/10/07/6-array-data-processing/">6_array_data_processing</a></h1><div class="content"><h3 id="6-数组处理批量数据"><a href="#6-数组处理批量数据" class="headerlink" title="6.数组处理批量数据"></a>6.数组处理批量数据</h3><h5 id="6-1-为数组赋值0-9,并将数组元素逆序输出"><a href="#6-1-为数组赋值0-9,并将数组元素逆序输出" class="headerlink" title="6.1 为数组赋值0~9,并将数组元素逆序输出"></a>6.1 为数组赋值0~9,并将数组元素逆序输出</h5><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> i,a[<span class="number">10</span>]; <span class="comment">//定义整型变量i ,整型数组a </span></span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<=<span class="number">9</span>;i++) <span class="comment">//循环for为数组元素赋值 </span></span><br><span class="line"> a[i]=i;</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">9</span>;i>=<span class="number">0</span>;i--) <span class="comment">//循环for 将数组元素逆序输出 </span></span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d"</span>,a[i]);</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h5 id="6-2-输出斐波那契数列第2-21项-斐波那契数列:0,1,1,2,3,5…"><a href="#6-2-输出斐波那契数列第2-21项-斐波那契数列:0,1,1,2,3,5…" class="headerlink" title="6.2 输出斐波那契数列第2~21项(斐波那契数列:0,1,1,2,3,5…)"></a>6.2 输出斐波那契数列第2~21项(斐波那契数列:0,1,1,2,3,5…)</h5><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> i;</span><br><span class="line"> <span class="keyword">int</span> f[<span class="number">20</span>]={<span class="number">1</span>,<span class="number">1</span>}; <span class="comment">//定义整型数组,第1,2项均为1 </span></span><br><span class="line"></span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">2</span>;i<<span class="number">20</span>;i++) <span class="comment">//循环结构for为整型数组第3至20项赋值 </span></span><br><span class="line"> f[i]=f[i<span class="number">-2</span>]+f[i<span class="number">-1</span>];</span><br><span class="line"></span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<<span class="number">20</span>;i++)</span><br><span class="line"> {</span><br><span class="line"> <span class="keyword">if</span>(i%<span class="number">5</span>==<span class="number">0</span>) <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%12d"</span>,f[i]); <span class="comment">//输出数组元素值,每数值占12列且右对齐 </span></span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h5 id="6-3-自定义10个数值,将数值按升序形式输出(冒泡排序法)"><a href="#6-3-自定义10个数值,将数值按升序形式输出(冒泡排序法)" class="headerlink" title="6.3 自定义10个数值,将数值按升序形式输出(冒泡排序法)"></a>6.3 自定义10个数值,将数值按升序形式输出(冒泡排序法)</h5><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><stdio.h></span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="keyword">int</span> a[<span class="number">10</span>];</span><br><span class="line"> <span class="keyword">int</span> i,j,t;</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"input 10 numbers :\n"</span>);</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<<span class="number">10</span>;i++) <span class="comment">//循环结构for 读取数据并存储 </span></span><br><span class="line"> <span class="built_in">scanf</span>(<span class="string">"%d"</span>,&a[i]);</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"> <span class="keyword">for</span>(j=<span class="number">0</span>;j<<span class="number">9</span>;j++) <span class="comment">//重复趟数总计9次,遍历每趟 </span></span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<<span class="number">9</span>-j;i++) <span class="comment">// 每趟内遍历数组元素 </span></span><br><span class="line"> <span class="keyword">if</span>(a[i]>a[i+<span class="number">1</span>])</span><br><span class="line"> {t=a[i];a[i]=a[i+<span class="number">1</span>];a[i+<span class="number">1</span>]=t;} <span class="comment">//条件判断,若前一项大于后一项,进行数值交换 </span></span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"the sorted numbers :\n"</span>);</span><br><span class="line"> <span class="keyword">for</span>(i=<span class="number">0</span>;i<<span class="number">10</span>;i++) <span class="comment">//循环结构输出sorted 后的数组元素 </span></span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d"</span>,a[i]); </span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line"> } </span><br></pre></td></tr></table></figure></div></article></div><div class="card"><article class="card-content article" role="article"><div class="article-meta is-size-7 is-uppercase level is-mobile"><div class="level-left"><span class="level-item">Posted <time dateTime="2020-10-07T02:44:11.000Z" title="2020-10-07T02:44:11.000Z">2020-10-07</time></span><span class="level-item">Updated <time dateTime="2020-10-07T03:10:01.190Z" title="2020-10-07T03:10:01.190Z">2020-10-07</time></span><span class="level-item"><a class="link-muted" href="/categories/Tools/">Tools</a><span> / </span><a class="link-muted" href="/categories/Tools/Blog/">Blog</a></span><span class="level-item">6 minutes read (About 939 words)</span></div></div><h1 class="title is-3 is-size-4-mobile"><a class="link-muted" href="/2020/10/07/Hexo-and-Github-Based-Personal-Blogs/">Hexo_github_搭建个人博客</a></h1><div class="content"><h3 id="个人博客搭建(github-nodejs-hexo-theme-3-Hexo-):"><a href="#个人博客搭建(github-nodejs-hexo-theme-3-Hexo-):" class="headerlink" title="个人博客搭建(github + nodejs + hexo + theme (3-Hexo)):"></a>个人博客搭建(github + nodejs + hexo + theme (3-Hexo)):</h3><h4 id="1-git-下载与安装"><a href="#1-git-下载与安装" class="headerlink" title="1.git 下载与安装"></a>1.git 下载与安装</h4><h5 id="git-简介:"><a href="#git-简介:" class="headerlink" title="git 简介:"></a>git 简介:</h5><p>Git (/ɡɪt/)is a distributed version-control system(分布式版本控制系统) for tracking changes in source code during software development.It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows[clarification needed].</p>
<p>The reasons why we use <strong>git</strong><br><img src="https://www.google.com/imgres?imgurl=https://www.nobledesktop.com/image/blog/git-branches-merge.png&imgrefurl=https://www.nobledesktop.com/blog/what-is-git-and-why-should-you-use-it&tbnid=RuCur-BGF1IeWM&vet=12ahUKEwiNieac4Z_sAhUHa5QKHZi8D6MQMygkegUIARCZAg..i&docid=fN9btghZUqB8kM&w=968&h=496&q=git&ved=2ahUKEwiNieac4Z_sAhUHa5QKHZi8D6MQMygkegUIARCZAg"></p>
<h5 id="git-下载与安装:"><a href="#git-下载与安装:" class="headerlink" title="git 下载与安装:"></a>git 下载与安装:</h5><p>you can download : <a target="_blank" rel="noopener" href="https://git-scm.com/downloads">website</a></p>
<p>the installtion just follows the defalut.</p>
<h5 id="git-使用:"><a href="#git-使用:" class="headerlink" title="git 使用:"></a>git 使用:</h5><p>git 中文教程: <a target="_blank" rel="noopener" href="https://www.liaoxuefeng.com/wiki/896043488029600">廖雪峰git 教程</a></p>
<h4 id="2-Nodejs-下载与安装"><a href="#2-Nodejs-下载与安装" class="headerlink" title="2.Nodejs 下载与安装"></a>2.Nodejs 下载与安装</h4><h5 id="nodejs-简介:"><a href="#nodejs-简介:" class="headerlink" title="nodejs 简介:"></a>nodejs <a target="_blank" rel="noopener" href="https://nodejs.org/en/about/">简介:</a></h5><p>As an <strong>asynchronous event-driven JavaScript runtime</strong>, Node.js is designed to <strong>build scalable network applications</strong>. In the following “hello world” example, many connections can be handled concurrently. Upon each connection, the callback is fired, but if there is no work to be done, Node.js will sleep.</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> http = <span class="built_in">require</span>(<span class="string">'http'</span>);</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> hostname = <span class="string">'127.0.0.1'</span>;</span><br><span class="line"><span class="keyword">const</span> port = <span class="number">3000</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> server = http.createServer(<span class="function">(<span class="params">req, res</span>) =></span> {</span><br><span class="line"> res.statusCode = <span class="number">200</span>;</span><br><span class="line"> res.setHeader(<span class="string">'Content-Type'</span>, <span class="string">'text/plain'</span>);</span><br><span class="line"> res.end(<span class="string">'Hello World'</span>);</span><br><span class="line">});</span><br><span class="line"></span><br><span class="line">server.listen(port, hostname, <span class="function">() =></span> {</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="string">`Server running at http://<span class="subst">${hostname}</span>:<span class="subst">${port}</span>/`</span>);</span><br><span class="line">});</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h5 id="nodejs-下载与安装:"><a href="#nodejs-下载与安装:" class="headerlink" title="nodejs 下载与安装:"></a>nodejs 下载与安装:</h5><p>根据操作系统选择相应 ‘source code’ 或者 ‘pre-built installer’<br>安装过程保持默认设置即可</p>
<h5 id="nodejs-使用:"><a href="#nodejs-使用:" class="headerlink" title="nodejs 使用:"></a>nodejs 使用:</h5><p>官方手册 <a target="_blank" rel="noopener" href="https://nodejs.org/dist/latest-v12.x/docs/api/">documentation</a></p>
<h4 id="3-Hexo-下载与安装"><a href="#3-Hexo-下载与安装" class="headerlink" title="3.Hexo 下载与安装"></a>3.Hexo 下载与安装</h4><h5 id="Hexo-简介:"><a href="#Hexo-简介:" class="headerlink" title="Hexo 简介:"></a>Hexo <a target="_blank" rel="noopener" href="https://hexo.io/docs/">简介:</a></h5><p>Hexo is a fast, simple and powerful blog framework. You write posts in Markdown (or other markup languages) and Hexo generates static files with a beautiful theme in seconds.</p>
<h5 id="Hexo-下载与安装:"><a href="#Hexo-下载与安装:" class="headerlink" title="Hexo 下载与安装:"></a>Hexo 下载与安装:</h5><h6 id="3-1-命令行安装"><a href="#3-1-命令行安装" class="headerlink" title="3.1. 命令行安装"></a>3.1. 命令行安装</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-cli -g</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>windows 系统可能出现报错: <code>win32 不支持 fsevents</code> , SKIPPING OPTIONAL DEPENDENCY, 不影响 hexo 基本功能<br><a target="_blank" rel="noopener" href="https://docs.npmjs.com/files/package.json#optionaldependencies">json optional dependencies</a> </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\hexo-cli\node_modules\chokidar\node_module</span><br><span class="line">s\fsevents):</span><br><span class="line">npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any</span><br><span class="line">"} (current: {"os":"win32","arch":"x64"})</span><br></pre></td></tr></table></figure>
<h6 id="3-2-检查-hexo-是否已经安装成功:"><a href="#3-2-检查-hexo-是否已经安装成功:" class="headerlink" title="3.2.检查 hexo 是否已经安装成功:"></a>3.2.检查 hexo 是否已经安装成功:</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo version</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">hexo-cli: 4.2.0</span><br><span class="line">os: Windows_NT</span><br><span class="line">node: 12.18.4</span><br><span class="line">v8: 7.8.279.23-</span><br><span class="line">uv: 1.38.0</span><br><span class="line">zlib: 1.2.11</span><br><span class="line">brotli: 1.0.7</span><br><span class="line">ares: 1.16.0</span><br><span class="line">modules: 72</span><br><span class="line">nghttp2: 1.41.0</span><br><span class="line">napi: 6</span><br><span class="line">llhttp: 2.1.2</span><br><span class="line">http_parser: 2.</span><br><span class="line">openssl: 1.1.1g</span><br><span class="line">cldr: 37.0</span><br><span class="line">icu: 67.1</span><br><span class="line">tz: 2019c</span><br><span class="line">unicode: 13.0</span><br></pre></td></tr></table></figure>
<h6 id="3-3-初始化-文件克隆-hexo-starter、Submodule-themes-landscape、;安装依赖"><a href="#3-3-初始化-文件克隆-hexo-starter、Submodule-themes-landscape、;安装依赖" class="headerlink" title="3.3.初始化(文件克隆 hexo-starter、Submodule themes/landscape、;安装依赖)"></a>3.3.初始化(文件克隆 hexo-starter、Submodule themes/landscape、;安装依赖)</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo init username.github.io</span><br></pre></td></tr></table></figure>
<p>初始化成功提醒:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">INFO Start blogging with Hexo!</span><br></pre></td></tr></table></figure>
<h6 id="3-4-测试-本地服务-是否可以启动"><a href="#3-4-测试-本地服务-是否可以启动" class="headerlink" title="3.4.测试 本地服务 是否可以启动"></a>3.4.测试 本地服务 是否可以启动</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo server</span><br></pre></td></tr></table></figure>
<p>server 成功提醒INFO :</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">INFO Validating config</span><br><span class="line">INFO Start processing</span><br><span class="line">INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.</span><br><span class="line">INFO Bye!</span><br></pre></td></tr></table></figure>
<h6 id="3-5-生成-SSH-Keys-并添加至-github-测试-本地与-github-通信是否成功"><a href="#3-5-生成-SSH-Keys-并添加至-github-测试-本地与-github-通信是否成功" class="headerlink" title="3.5. 生成 SSH Keys, 并添加至 github, 测试 本地与 github 通信是否成功"></a>3.5. 生成 SSH Keys, 并添加至 github, 测试 本地与 github 通信是否成功</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -C "***@***.com"</span><br></pre></td></tr></table></figure>
<p>KEY 添加方法 : Github –> settings —> SSH keys setting </p>
<p>通信测试 : </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh -T [email protected]</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Hi ***! You've successfully authenticated, but GitHub does not provide shell access.</span><br></pre></td></tr></table></figure>
<p>or</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ ssh [email protected]</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Hi ******! You've successfully authenticated, but GitHub does not provide shell access.</span><br><span class="line">Connection to github.com closed.</span><br></pre></td></tr></table></figure>
<h6 id="3-6-配置-SSH-服务-、-config-yml文件-:-如未配置,则每次-hexo-deploy-均需要输入用户名及密码"><a href="#3-6-配置-SSH-服务-、-config-yml文件-:-如未配置,则每次-hexo-deploy-均需要输入用户名及密码" class="headerlink" title="3.6. 配置 SSH 服务 、_config.yml文件 : 如未配置,则每次 hexo deploy 均需要输入用户名及密码:"></a>3.6. 配置 SSH 服务 、<code>_config.yml</code>文件 : 如未配置,则每次 <code>hexo deploy</code> 均需要输入用户名及密码:</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ git config --global user.name "******"// github用户名</span><br><span class="line">$ git config --global user.email "******"// github注册邮箱</span><br></pre></td></tr></table></figure>
<p><code>_config.yml</code>文件更改为:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line"> type: git</span><br><span class="line"> repository: [email protected]:username/username.github.io.git</span><br><span class="line"> branch: master</span><br></pre></td></tr></table></figure>
<p>不当写法:此种写法为 <code>hexo2.*</code> 版本书写规则,执行 <code>hexo d</code> 时会导致报错 <code>Deployer not found: github or Deployer not found: git </code> , 可通过安装插件解决 <code>npm install hexo-deployer-git --save</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line"> type: github</span><br><span class="line"> repository: https://github.com/username/username.github.io.git</span><br><span class="line"> branch: master</span><br></pre></td></tr></table></figure>
<h5 id="4-域名解析:"><a href="#4-域名解析:" class="headerlink" title="4. 域名解析:"></a>4. 域名解析:</h5><p>添加域名解析后,可使个性化域名指向博客 。<br>为域名添加两条记录:<br>主机记录(@ ; www); 记录类型(A ; CNAME); 解析线路 (默认 ; 默认) ; 记录值 ( IP ; ***.github.io) ; TTL (10min ;10min)</p>
<p>IP 获取方式 : </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ping ***.github.com </span><br></pre></td></tr></table></figure>
<h5 id="5-Hexo-使用教程(主题更换):"><a href="#5-Hexo-使用教程(主题更换):" class="headerlink" title="5. Hexo 使用教程(主题更换):"></a>5. Hexo 使用教程(主题更换):</h5><p><a target="_blank" rel="noopener" href="https://hexo.io/docs/">官方教程</a><br><a target="_blank" rel="noopener" href="https://yelog.org/2017/03/23/3-hexo-instruction/">3-hexo yelog</a></p>
</div></article></div></div><div class="column column-left is-4-tablet is-4-desktop is-4-widescreen order-1"><div class="card widget" data-type="profile"><div class="card-content"><nav class="level"><div class="level-item has-text-centered flex-shrink-1"><div><figure class="image is-128x128 mx-auto mb-2"><img class="avatar" src="/img/avatar.png" alt="Arthur"></figure><p class="title is-size-4 is-block" style="line-height:inherit;">Arthur</p><p class="is-size-6 is-block">Programmer</p><p class="is-size-6 is-flex justify-content-center"><i class="fas fa-map-marker-alt mr-1"></i><span>CN</span></p></div></div></nav><nav class="level is-mobile"><div class="level-item has-text-centered is-marginless"><div><p class="heading">Posts</p><a href="/archives"><p class="title">5</p></a></div></div><div class="level-item has-text-centered is-marginless"><div><p class="heading">Categories</p><a href="/categories"><p class="title">7</p></a></div></div><div class="level-item has-text-centered is-marginless"><div><p class="heading">Tags</p><a href="/tags"><p class="title">8</p></a></div></div></nav><div class="level"><a class="level-item button is-primary is-rounded" href="/" target="_blank" rel="noopener">Follow</a></div><div class="level is-mobile"><a class="level-item button is-transparent is-marginless" target="_blank" rel="noopener" title="Github" href="https://github.com/mit2021"><i class="fab fa-github"></i></a><a class="level-item button is-transparent is-marginless" target="_blank" rel="noopener" title="Facebook" href="https://facebook.com"><i class="fab fa-facebook"></i></a><a class="level-item button is-transparent is-marginless" target="_blank" rel="noopener" title="Twitter" href="https://twitter.com"><i class="fab fa-twitter"></i></a><a class="level-item button is-transparent is-marginless" target="_blank" rel="noopener" title="Dribbble" href="https://dribbble.com"><i class="fab fa-dribbble"></i></a><a class="level-item button is-transparent is-marginless" target="_blank" rel="noopener" title="RSS" href="/"><i class="fas fa-rss"></i></a></div></div></div><!--!--><div class="card widget" data-type="links"><div class="card-content"><div class="menu"><h3 class="menu-label">Links</h3><ul class="menu-list"><li><a class="level is-mobile" href="https://hexo.io" target="_blank" rel="noopener"><span class="level-left"><span class="level-item">Hexo</span></span><span class="level-right"><span class="level-item tag">hexo.io</span></span></a></li><li><a class="level is-mobile" href="https://bulma.io" target="_blank" rel="noopener"><span class="level-left"><span class="level-item">Bulma</span></span><span class="level-right"><span class="level-item tag">bulma.io</span></span></a></li></ul></div></div></div><div class="card widget" data-type="categories"><div class="card-content"><div class="menu"><h3 class="menu-label">Categories</h3><ul class="menu-list"><li><a class="level is-mobile" href="/categories/Data-Structure/"><span class="level-start"><span class="level-item">Data Structure</span></span><span class="level-end"><span class="level-item tag">1</span></span></a><ul><li><a class="level is-mobile" href="/categories/Data-Structure/C/"><span class="level-start"><span class="level-item">C</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li></ul></li><li><a class="level is-mobile" href="/categories/Programming/"><span class="level-start"><span class="level-item">Programming</span></span><span class="level-end"><span class="level-item tag">2</span></span></a><ul><li><a class="level is-mobile" href="/categories/Programming/C/"><span class="level-start"><span class="level-item">C</span></span><span class="level-end"><span class="level-item tag">2</span></span></a></li></ul></li><li><a class="level is-mobile" href="/categories/R/"><span class="level-start"><span class="level-item">R</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/Tools/"><span class="level-start"><span class="level-item">Tools</span></span><span class="level-end"><span class="level-item tag">1</span></span></a><ul><li><a class="level is-mobile" href="/categories/Tools/Blog/"><span class="level-start"><span class="level-item">Blog</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li></ul></li></ul></div></div></div><div class="card widget" data-type="recent-posts"><div class="card-content"><h3 class="menu-label">Recents</h3><article class="media"><div class="media-content"><p class="date"><time dateTime="2020-11-23T01:08:16.288Z">2020-11-23</time></p><p class="title"><a href="/2020/11/23/Using-R-to-Calculating-the-Distance/"> </a></p><p class="categories"><a href="/categories/R/">R</a></p></div></article><article class="media"><div class="media-content"><p class="date"><time dateTime="2020-10-10T03:25:33.000Z">2020-10-10</time></p><p class="title"><a href="/2020/10/10/DS-1-1-Recursion/">DS_1_1_Recursion</a></p><p class="categories"><a href="/categories/Data-Structure/">Data Structure</a> / <a href="/categories/Data-Structure/C/">C</a></p></div></article><article class="media"><div class="media-content"><p class="date"><time dateTime="2020-10-08T05:02:36.000Z">2020-10-08</time></p><p class="title"><a href="/2020/10/08/6-array-data-processing-2/">6_array_data_processing_2</a></p><p class="categories"><a href="/categories/Programming/">Programming</a> / <a href="/categories/Programming/C/">C</a></p></div></article><article class="media"><div class="media-content"><p class="date"><time dateTime="2020-10-07T14:28:02.000Z">2020-10-07</time></p><p class="title"><a href="/2020/10/07/6-array-data-processing/">6_array_data_processing</a></p><p class="categories"><a href="/categories/Programming/">Programming</a> / <a href="/categories/Programming/C/">C</a></p></div></article><article class="media"><div class="media-content"><p class="date"><time dateTime="2020-10-07T02:44:11.000Z">2020-10-07</time></p><p class="title"><a href="/2020/10/07/Hexo-and-Github-Based-Personal-Blogs/">Hexo_github_搭建个人博客</a></p><p class="categories"><a href="/categories/Tools/">Tools</a> / <a href="/categories/Tools/Blog/">Blog</a></p></div></article></div></div><div class="card widget" data-type="archives"><div class="card-content"><div class="menu"><h3 class="menu-label">Archives</h3><ul class="menu-list"><li><a class="level is-mobile" href="/archives/2020/11/"><span class="level-start"><span class="level-item">November 2020</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/archives/2020/10/"><span class="level-start"><span class="level-item">October 2020</span></span><span class="level-end"><span class="level-item tag">4</span></span></a></li></ul></div></div></div><div class="card widget" data-type="tags"><div class="card-content"><div class="menu"><h3 class="menu-label">Tags</h3><div class="field is-grouped is-grouped-multiline"><div class="control"><a class="tags has-addons" href="/tags/C/"><span class="tag">C</span><span class="tag">3</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Distance/"><span class="tag">Distance</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/R/"><span class="tag">R</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/array/"><span class="tag">array</span><span class="tag">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/github/"><span class="tag">github</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/hexo/"><span class="tag">hexo</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/recursion/"><span class="tag">recursion</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/statistics/"><span class="tag">statistics</span><span class="tag">1</span></a></div></div></div></div></div><div class="card widget" data-type="subscribe-email"><div class="card-content"><div class="menu"><h3 class="menu-label">Subscribe for updates</h3><form action="https://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open('https://feedburner.google.com/fb/a/mailverify?uri=','popupwindow','scrollbars=yes,width=550,height=520');return true"><input type="hidden" value="" name="uri"><input type="hidden" name="loc" value="en_US"><div class="field has-addons"><div class="control has-icons-left is-expanded"><input class="input" name="email" type="email" placeholder="Email"><span class="icon is-small is-left"><i class="fas fa-envelope"></i></span></div><div class="control"><input class="button" type="submit" value="Subscribe"></div></div></form></div></div></div><div class="card widget"><div class="card-content"><div class="notification is-danger">You need to set <code>client_id</code> and <code>slot_id</code> to show this AD unit. Please set it in <code>_config.yml</code>.</div></div></div></div><!--!--></div></div></section><footer class="footer"><div class="container"><div class="level"><div class="level-start"><a class="footer-logo is-block mb-2" href="/"><img src="/img/logo.svg" alt="Hexo" height="28"></a><p class="is-size-7"><span>© 2020 John Doe</span> Powered by <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a> & <a href="https://github.com/ppoffice/hexo-theme-icarus" target="_blank" rel="noopener">Icarus</a></p></div><div class="level-end"><div class="field has-addons"><p class="control"><a class="button is-transparent is-large" target="_blank" rel="noopener" title="Creative Commons" href="https://creativecommons.org/"><i class="fab fa-creative-commons"></i></a></p><p class="control"><a class="button is-transparent is-large" target="_blank" rel="noopener" title="Attribution 4.0 International" href="https://creativecommons.org/licenses/by/4.0/"><i class="fab fa-creative-commons-by"></i></a></p></div></div></div></div></footer><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/[email protected]/min/moment-with-locales.min.js"></script><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/clipboard.min.js" async></script><script>moment.locale("en");</script><script>var IcarusThemeSettings = {
article: {
highlight: {
clipboard: true,
fold: 'unfolded'
}
}
};</script><script src="/js/column.js"></script><script src="/js/animation.js"></script><a id="back-to-top" title="Back to top" href="javascript:;"><i class="fas fa-chevron-up"></i></a><script src="/js/back_to_top.js" defer></script><!--!--><!--!--><!--!--><script src="https://cdn.jsdelivr.net/npm/[email protected]/build/cookieconsent.min.js" defer></script><script>window.addEventListener("load", () => {
window.cookieconsent.initialise({
type: "info",
theme: "edgeless",
static: false,
position: "bottom-left",
content: {
message: "This website uses cookies to improve your experience.",
dismiss: "Got it!",
allow: "Allow cookies",
deny: "Decline",
link: "Learn more",
policy: "Cookie Policy",
href: "https://www.cookiesandyou.com/",
},
palette: {
popup: {
background: "#edeff5",
text: "#838391"
},
button: {
background: "#4b81e8"
},
},
});
});</script><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/lightgallery.min.js" defer></script><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/jquery.justifiedGallery.min.js" defer></script><script>window.addEventListener("load", () => {
if (typeof $.fn.lightGallery === 'function') {
$('.article').lightGallery({ selector: '.gallery-item' });
}
if (typeof $.fn.justifiedGallery === 'function') {
if ($('.justified-gallery > p > .gallery-item').length) {
$('.justified-gallery > p > .gallery-item').unwrap();
}
$('.justified-gallery').justifiedGallery();
}
});</script><!--!--><!--!--><!--!--><!--!--><!--!--><script src="/js/main.js" defer></script><div class="searchbox"><div class="searchbox-container"><div class="searchbox-header"><div class="searchbox-input-container"><input class="searchbox-input" type="text" placeholder="Type something..."></div><a class="searchbox-close" href="javascript:;">×</a></div><div class="searchbox-body"></div></div></div><script src="/js/insight.js" defer></script><script>document.addEventListener('DOMContentLoaded', function () {
loadInsight({"contentUrl":"/content.json"}, {"hint":"Type something...","untitled":"(Untitled)","posts":"Posts","pages":"Pages","categories":"Categories","tags":"Tags"});
});</script></body></html>