This commit is contained in:
krahets 2023-03-01 03:16:47 +08:00
parent d8f9fb1aad
commit 24c6478308
2 changed files with 12 additions and 9 deletions

View file

@ -446,7 +446,7 @@ $$
=== "JavaScript"
```javascript title=""
function algorithm(n){
function algorithm(n) {
var a = 1; // +1
a += 1; // +1
a *= 2; // +1
@ -454,7 +454,6 @@ $$
for(let i = 0; i < n; i++){ // +1每轮都执行 i ++
console.log(0); // +1
}
}
```
@ -469,7 +468,6 @@ $$
for(let i = 0; i < n; i++){ // +1每轮都执行 i ++
console.log(0); // +1
}
}
```
@ -490,12 +488,14 @@ $$
=== "C#"
```csharp title=""
void algorithm(int n) {
void algorithm(int n)
{
int a = 1; // +1
a = a + 1; // +1
a = a * 2; // +1
// 循环 n 次
for (int i = 0; i < n; i++) { // +1每轮都执行 i ++
for (int i = 0; i < n; i++) // +1每轮都执行 i ++
{
Console.WriteLine(0); // +1
}
}

View file

@ -354,15 +354,18 @@ comments: true
```csharp title="hash_map.cs"
/* 遍历哈希表 */
// 遍历键值对 Key->Value
foreach (var kv in map) {
foreach (var kv in map)
{
Console.WriteLine(kv.Key + " -> " + kv.Value);
}
// 单独遍历键 key
foreach (int key in map.Keys) {
foreach (int key in map.Keys)
{
Console.WriteLine(key);
}
// 单独遍历值 value
foreach (String val in map.Values) {
foreach (String val in map.Values)
{
Console.WriteLine(val);
}
```