Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ len(arr) == 2

##### c++
```c++
sizeof arr /sizeof(arr[0]) == 2;
sizeof(arr)/sizeof(arr[0]) == 2;
// C++ 11
int length = std::end(arr) - std::begin(arr);
```
Expand Down Expand Up @@ -579,8 +579,9 @@ else { }

##### c++
```c++


if (true) {
} else if (true) {
} else { }

```

Expand Down Expand Up @@ -621,15 +622,35 @@ for _, value := range array {}
##### c++
```c++
// 普通for循环

for( int a = 1; a < 10; a ++ )
{
}
// 仅判断

for(; a < 10;) {}
// 无限循环

for( ; ; )
{
}
// 遍历索引
for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)

// 遍历元素

for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
{
int v = arr[i]
}
// C++ 11
for (auto v : arr)
for (const int& v : arr)
for (auto&& v : arr)
// using for_each
std::vector<int> varr(arr, arr + sizeof(arr)/sizeof(arr[0]));
std::for_each(varr.begin(), varr.end(), [](int &v){
std::cout << " " << v;
});
std::for_each(varr.cbegin(), varr.cend(), [](const int &v){
std::cout << " " << v;
});
```


Expand Down
35 changes: 28 additions & 7 deletions data/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool f = false;
int arr[2] = {1, 2};
int arr[] {1, 2};
// - 数组-获取长度
sizeof arr /sizeof(arr[0]) == 2;
sizeof(arr)/sizeof(arr[0]) == 2;
// C++ 11
int length = std::end(arr) - std::begin(arr);
// - 数组-遍历
Expand Down Expand Up @@ -125,20 +125,41 @@ std::ssub_match capture1Res = submatch[1];
std::string capture1Res = capture1Res.str();
// capture1 === 'b'
// - 条件


if (true) {
} else if (true) {
} else { }

// - 循环-for
// 普通for循环

for( int a = 1; a < 10; a ++ )
{
}
// 仅判断

for(; a < 10;) {}
// 无限循环

for( ; ; )
{
}
// 遍历索引
for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)

// 遍历元素

for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
{
int v = arr[i]
}
// C++ 11
for (auto v : arr)
for (const int& v : arr)
for (auto&& v : arr)
// using for_each
std::vector<int> varr(arr, arr + sizeof(arr)/sizeof(arr[0]));
std::for_each(varr.begin(), varr.end(), [](int &v){
std::cout << " " << v;
});
std::for_each(varr.cbegin(), varr.cend(), [](const int &v){
std::cout << " " << v;
});
// - 循环-while

// - 选择-switch
Expand Down
35 changes: 28 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
int arr[] {1, 2};</code></pre></div></div></div></div>
</div><div class="line">
<div class="class" style="padding-right: 0px">获取长度</div>
<div class="child"><div class="line"><div class="lang"><div class="code"><pre><code class="typescript">arr.length === 2</code></pre></div></div><div class="lang"><div class="code"><pre><code class="golang">len(arr) == 2</code></pre></div></div><div class="lang"><div class="code"><pre><code class="c++">sizeof arr /sizeof(arr[0]) == 2;
<div class="child"><div class="line"><div class="lang"><div class="code"><pre><code class="typescript">arr.length === 2</code></pre></div></div><div class="lang"><div class="code"><pre><code class="golang">len(arr) == 2</code></pre></div></div><div class="lang"><div class="code"><pre><code class="c++">sizeof(arr)/sizeof(arr[0]) == 2;
// C++ 11
int length = std::end(arr) - std::begin(arr);</code></pre></div></div></div></div>
</div><div class="line">
Expand Down Expand Up @@ -302,8 +302,9 @@
} else if (true) {
} else { }</code></pre></div></div><div class="lang"><div class="code"><pre><code class="golang">if true {}
else if true {}
else { }</code></pre></div></div><div class="lang"><div class="code"><pre><code class="c++">

else { }</code></pre></div></div><div class="lang"><div class="code"><pre><code class="c++">if (true) {
} else if (true) {
} else { }
</code></pre></div></div></div></div>
</div><div class="line">
<div class="class" style="">循环</div>
Expand All @@ -329,15 +330,35 @@
for index, _ := range array {}
// 遍历元素
for _, value := range array {}</code></pre></div></div><div class="lang"><div class="code"><pre><code class="c++">// 普通for循环

for( int a = 1; a &lt; 10; a ++ )
{
}
// 仅判断

for(; a &lt; 10;) {}
// 无限循环

for( ; ; )
{
}
// 遍历索引
for (int i = 0; i &lt; sizeof(arr)/sizeof(arr[0]); i++)

// 遍历元素
</code></pre></div></div></div></div>
for (int i = 0; i &lt; sizeof(arr)/sizeof(arr[0]); i++)
{
int v = arr[i]
}
// C++ 11
for (auto v : arr)
for (const int& v : arr)
for (auto&& v : arr)
// using for_each
std::vector&lt;int&gt; varr(arr, arr + sizeof(arr)/sizeof(arr[0]));
std::for_each(varr.begin(), varr.end(), [](int &v){
std::cout &lt;&lt; " " &lt;&lt; v;
});
std::for_each(varr.cbegin(), varr.cend(), [](const int &v){
std::cout &lt;&lt; " " &lt;&lt; v;
});</code></pre></div></div></div></div>
</div><div class="line">
<div class="class" style="padding-right: 0px">while</div>
<div class="child"><div class="line"><div class="lang"><div class="code"><pre><code class="typescript">while(Math.random()&lt;0.5) {}</code></pre></div></div><div class="lang"><div class="code"><pre><code class="golang">for i&lt;10 {}</code></pre></div></div><div class="lang"><div class="code"><pre><code class="c++"></code></pre></div></div></div></div>
Expand Down