Re-translate the Japanese version (#1871)

* Retranslate Japanese docs with GPT-5.4

* Retranslate Japanese code with GPT-5.4
This commit is contained in:
Yudong Jin
2026-03-30 07:30:15 +08:00
committed by GitHub
parent fe6443235b
commit d7b2277d2b
1444 changed files with 83312 additions and 8363 deletions
@@ -0,0 +1,85 @@
/**
* File: array_stack.swift
* Created Time: 2023-01-09
* Author: nuomi1 (nuomi1@qq.com)
*/
/* */
class ArrayStack {
private var stack: [Int]
init() {
//
stack = []
}
/* */
func size() -> Int {
stack.count
}
/* */
func isEmpty() -> Bool {
stack.isEmpty
}
/* */
func push(num: Int) {
stack.append(num)
}
/* */
@discardableResult
func pop() -> Int {
if isEmpty() {
fatalError("スタックが空です")
}
return stack.removeLast()
}
/* */
func peek() -> Int {
if isEmpty() {
fatalError("スタックが空です")
}
return stack.last!
}
/* List Array */
func toArray() -> [Int] {
stack
}
}
@main
enum _ArrayStack {
/* Driver Code */
static func main() {
/* */
let stack = ArrayStack()
/* */
stack.push(num: 1)
stack.push(num: 3)
stack.push(num: 2)
stack.push(num: 5)
stack.push(num: 4)
print("スタック stack = \(stack.toArray())")
/* */
let peek = stack.peek()
print("スタックトップ要素 peek = \(peek)")
/* */
let pop = stack.pop()
print("ポップした要素 pop = \(pop)、ポップ後の stack = \(stack.toArray())")
/* */
let size = stack.size()
print("スタックの長さ size = \(size)")
/* */
let isEmpty = stack.isEmpty()
print("スタックが空かどうか = \(isEmpty)")
}
}