mirror of
https://github.com/krahets/hello-algo.git
synced 2026-06-15 14:48:05 +08:00
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:
39
ja/codes/csharp/chapter_stack_and_queue/queue.cs
Normal file
39
ja/codes/csharp/chapter_stack_and_queue/queue.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* File: queue.cs
|
||||
* Created Time: 2022-12-23
|
||||
* Author: haptear (haptear@hotmail.com)
|
||||
*/
|
||||
|
||||
namespace hello_algo.chapter_stack_and_queue;
|
||||
|
||||
public class queue {
|
||||
[Test]
|
||||
public void Test() {
|
||||
/* キューを初期化 */
|
||||
Queue<int> queue = new();
|
||||
|
||||
/* 要素をエンキュー */
|
||||
queue.Enqueue(1);
|
||||
queue.Enqueue(3);
|
||||
queue.Enqueue(2);
|
||||
queue.Enqueue(5);
|
||||
queue.Enqueue(4);
|
||||
Console.WriteLine("キュー queue = " + string.Join(",", queue));
|
||||
|
||||
/* キュー先頭の要素にアクセス */
|
||||
int peek = queue.Peek();
|
||||
Console.WriteLine("先頭要素 peek = " + peek);
|
||||
|
||||
/* 要素をデキュー */
|
||||
int pop = queue.Dequeue();
|
||||
Console.WriteLine("デキューした要素 pop = " + pop + "、デキュー後の queue = " + string.Join(",", queue));
|
||||
|
||||
/* キューの長さを取得 */
|
||||
int size = queue.Count;
|
||||
Console.WriteLine("キューの長さ size = " + size);
|
||||
|
||||
/* キューが空かどうかを判定 */
|
||||
bool isEmpty = queue.Count == 0;
|
||||
Console.WriteLine("キューが空かどうか = " + isEmpty);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user