Skip to content

Commit

Permalink
feat: update code blocks (doocs#2827)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme authored May 17, 2024
1 parent 9ffe05e commit c29b144
Show file tree
Hide file tree
Showing 6,756 changed files with 76,420 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
14 changes: 14 additions & 0 deletions basic/sorting/BubbleSort/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<!-- tabs:start -->

#### Python3

```python
def bubbleSort(arr):
n = len(arr)
Expand Down Expand Up @@ -37,6 +39,8 @@ bubbleSort(arr)
print(arr)
```

#### Java

```java
import java.util.Arrays;

Expand Down Expand Up @@ -69,6 +73,8 @@ public class BubbleSort {
}
```

#### C++

```cpp
#include <iostream>
#include <vector>
Expand Down Expand Up @@ -97,6 +103,8 @@ int main() {
}
```
#### Go
```go
package main
Expand All @@ -122,6 +130,8 @@ func main() {
}
```

#### Rust

```rust
fn bubble_sort(nums: &mut Vec<i32>) {
let n = nums.len();
Expand All @@ -143,6 +153,8 @@ fn main() {
}
```

#### JavaScript

```js
function bubbleSort(inputArr) {
for (let i = inputArr.length - 1; i > 0; i--) {
Expand All @@ -168,6 +180,8 @@ const arr = [6, 3, 2, 1, 5];
console.log(bubbleSort(arr));
```

#### C#

```cs
using static System.Console;
namespace Pro;
Expand Down
16 changes: 16 additions & 0 deletions basic/sorting/HeapSort/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ for (int i = n / 2; i > 0; --i) {

### **Python3**

#### Python3

```python
n, m = list(map(int, input().split(" ")))
h = [0] + list(map(int, input().split(" ")))
Expand Down Expand Up @@ -112,6 +114,8 @@ print(' '.join(list(map(str, res))))

### **Java**

#### Java

```java
import java.util.Scanner;

Expand Down Expand Up @@ -167,6 +171,8 @@ public class Main {

### **Rust**

#### Rust

```rust
use std::io;

Expand Down Expand Up @@ -232,6 +238,8 @@ fn main() -> io::Result<()> {

### **Go**

#### Go

```go
package main

Expand Down Expand Up @@ -294,6 +302,8 @@ func main() {

<!-- tabs:start -->

#### Python3

```python
n, m = list(map(int, input().split(" ")))
h = [0] + list(map(int, input().split(" ")))
Expand Down Expand Up @@ -331,6 +341,8 @@ for i in range(m):
print(' '.join(list(map(str, res))))
```

#### Java

```java
import java.util.Scanner;

Expand Down Expand Up @@ -384,6 +396,8 @@ public class Main {
}
```

#### Go

```go
package main

Expand Down Expand Up @@ -438,6 +452,8 @@ func main() {
}
```

#### Rust

```rust
use std::io;

Expand Down
14 changes: 14 additions & 0 deletions basic/sorting/InsertionSort/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

<!-- tabs:start -->

#### Python3

```python
def insertion_sort(array):
for i in range(len(array)):
Expand All @@ -34,6 +36,8 @@ array = [10, 17, 50, 7, 30, 24, 27, 45, 15, 5, 36, 21]
print(insertion_sort(array))
```

#### Java

```java
import java.util.Arrays;

Expand All @@ -57,6 +61,8 @@ public class InsertionSort {
}
```

#### C++

```cpp
#include <iostream>
#include <vector>
Expand Down Expand Up @@ -96,6 +102,8 @@ int main() {
}
```
#### Go
```go
package main
Expand All @@ -118,6 +126,8 @@ func main() {
}
```

#### Rust

```rust
fn insertion_sort(nums: &mut Vec<i32>) {
let n = nums.len();
Expand All @@ -139,6 +149,8 @@ fn main() {
}
```

#### JavaScript

```js
function insertionSort(inputArr) {
let len = inputArr.length;
Expand All @@ -158,6 +170,8 @@ let arr = [6, 3, 2, 1, 5];
console.log(insertionSort(arr));
```

#### C#

```cs
using System.Diagnostics;
using static System.Console;
Expand Down
12 changes: 12 additions & 0 deletions basic/sorting/MergeSort/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ void mergeSort(int[] nums, int left, int right) {

<!-- tabs:start -->

#### Python3

```python
N = int(input())
nums = list(map(int, input().split()))
Expand Down Expand Up @@ -110,6 +112,8 @@ merge_sort(nums, 0, N - 1)
print(' '.join(list(map(str, nums))))
```

#### Java

```java
import java.util.Scanner;

Expand Down Expand Up @@ -157,6 +161,8 @@ public class Main {
}
```

#### C++

```cpp
#include <iostream>

Expand Down Expand Up @@ -194,6 +200,8 @@ int main() {
}
```
#### Go
```go
package main
Expand Down Expand Up @@ -246,6 +254,8 @@ func main() {
}
```

#### Rust

```rust
use std::io;

Expand Down Expand Up @@ -306,6 +316,8 @@ fn main() -> io::Result<()> {
}
```

#### JavaScript

```js
var buf = '';

Expand Down
12 changes: 12 additions & 0 deletions basic/sorting/QuickSort/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void quickSort(int[] nums, int left, int right) {

<!-- tabs:start -->

#### Python3

```python
N = int(input())
nums = list(map(int, input().split()))
Expand Down Expand Up @@ -95,6 +97,8 @@ quick_sort(nums, 0, N - 1)
print(' '.join(list(map(str, nums))))
```

#### Java

```java
import java.util.Scanner;

Expand Down Expand Up @@ -135,6 +139,8 @@ public class Main {
}
```

#### C++

```cpp
#include <iostream>

Expand Down Expand Up @@ -169,6 +175,8 @@ int main() {
}
```
#### Go
```go
package main
Expand Down Expand Up @@ -217,6 +225,8 @@ func main() {
}
```

#### Rust

```rust
use rand::Rng; // 0.7.2
use std::io;
Expand Down Expand Up @@ -271,6 +281,8 @@ fn main() -> io::Result<()> {
}
```

#### JavaScript

```js
var buf = '';

Expand Down
14 changes: 14 additions & 0 deletions basic/sorting/SelectionSort/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

<!-- tabs:start -->

#### Python3

```python
def selection_sort(arr):
n = len(arr)
Expand All @@ -22,6 +24,8 @@ selection_sort(arr)
print(arr)
```

#### Java

```java
import java.util.Arrays;

Expand Down Expand Up @@ -53,6 +57,8 @@ public class SelectionSort {
}
```

#### C++

```cpp
#include <iostream>
#include <vector>
Expand Down Expand Up @@ -91,6 +97,8 @@ int main(void) {
}
```
#### Go
```go
package main
Expand All @@ -115,6 +123,8 @@ func main() {
}
```

#### Rust

```rust
fn selection_sort(nums: &mut Vec<i32>) {
let n = nums.len();
Expand All @@ -138,6 +148,8 @@ fn main() {
}
```

#### JavaScript

```js
function selectionSort(inputArr) {
let len = inputArr.length;
Expand All @@ -159,6 +171,8 @@ let arr = [6, 3, 2, 1, 5];
console.log(selectionSort(arr));
```

#### C#

```cs
using static System.Console;
namespace Pro;
Expand Down
Loading

0 comments on commit c29b144

Please sign in to comment.