This commit is contained in:
krahets
2023-09-04 03:16:55 +08:00
parent f07e94ab0c
commit 8f74a87eba
54 changed files with 23015 additions and 23015 deletions
+56 -56
View File
@@ -51,26 +51,6 @@ comments: true
换句话说,**基本数据类型提供了数据的“内容类型”,而数据结构提供了数据的“组织方式”**。例如以下代码,我们用相同的数据结构(数组)来存储与表示不同的基本数据类型,包括 `int``float``char``bool` 等。
=== "Java"
```java title=""
// 使用多种基本数据类型来初始化数组
int[] numbers = new int[5];
float[] decimals = new float[5];
char[] characters = new char[5];
boolean[] bools = new boolean[5];
```
=== "C++"
```cpp title=""
// 使用多种基本数据类型来初始化数组
int numbers[5];
float decimals[5];
char characters[5];
bool bools[5];
```
=== "Python"
```python title=""
@@ -84,6 +64,36 @@ comments: true
data = [0, 0.0, 'a', False, ListNode(0)]
```
=== "C++"
```cpp title=""
// 使用多种基本数据类型来初始化数组
int numbers[5];
float decimals[5];
char characters[5];
bool bools[5];
```
=== "Java"
```java title=""
// 使用多种基本数据类型来初始化数组
int[] numbers = new int[5];
float[] decimals = new float[5];
char[] characters = new char[5];
boolean[] bools = new boolean[5];
```
=== "C#"
```csharp title=""
// 使用多种基本数据类型来初始化数组
int[] numbers = new int[5];
float[] decimals = new float[5];
char[] characters = new char[5];
bool[] bools = new bool[5];
```
=== "Go"
```go title=""
@@ -94,6 +104,16 @@ comments: true
var bools = [5]bool{}
```
=== "Swift"
```swift title=""
// 使用多种基本数据类型来初始化数组
let numbers = Array(repeating: Int(), count: 5)
let decimals = Array(repeating: Double(), count: 5)
let characters = Array(repeating: Character("a"), count: 5)
let bools = Array(repeating: Bool(), count: 5)
```
=== "JS"
```javascript title=""
@@ -110,42 +130,6 @@ comments: true
const bools: boolean[] = [];
```
=== "C"
```c title=""
// 使用多种基本数据类型来初始化数组
int numbers[10];
float decimals[10];
char characters[10];
bool bools[10];
```
=== "C#"
```csharp title=""
// 使用多种基本数据类型来初始化数组
int[] numbers = new int[5];
float[] decimals = new float[5];
char[] characters = new char[5];
bool[] bools = new bool[5];
```
=== "Swift"
```swift title=""
// 使用多种基本数据类型来初始化数组
let numbers = Array(repeating: Int(), count: 5)
let decimals = Array(repeating: Double(), count: 5)
let characters = Array(repeating: Character("a"), count: 5)
let bools = Array(repeating: Bool(), count: 5)
```
=== "Zig"
```zig title=""
```
=== "Dart"
```dart title=""
@@ -161,3 +145,19 @@ comments: true
```rust title=""
```
=== "C"
```c title=""
// 使用多种基本数据类型来初始化数组
int numbers[10];
float decimals[10];
char characters[10];
bool bools[10];
```
=== "Zig"
```zig title=""
```