📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)

ページの作成:「== ジャグ配列とは == ジャグ配列とは、配列の中の要素が配列となっている配列である。<br> そのため、配列の配列と呼ばれる…」
 
文字列「</source>」を「</syntaxhighlight>」に置換
 
(3人の利用者による、間の4版が非表示)
34行目: 34行目:
| [0] || [0][0] || [0][1] || [0][2]
| [0] || [0][0] || [0][1] || [0][2]
|-
|-
| [1] || [1][0] || [1][1] || [1][2]
| [1] || [1][0] || ||  
|-
|-
| [2] || [2][0] || [2][1] || [2][2]
| [2] || [2][0] || [2][1] ||  
|-
|-
| [3] || [3][0] || [3][1] || [3][2]
| [3] || [3][0] || [3][1] || [3][2]
42行目: 42行目:
</center>
</center>
<br>
<br>
  <source lang="c#">
  <syntaxhighlight lang="c#">
  // ジャグ配列の宣言と初期化
  // ジャグ配列の宣言と初期化
  string[][] strJagStudent = {
  string[][] strJagStudent = {
81行目: 81行目:
  strJagStudent[3][1] = “男”;
  strJagStudent[3][1] = “男”;
  strJagStudent[3][2] = “野球”;
  strJagStudent[3][2] = “野球”;
  </source>
  </syntaxhighlight>
<br><br>
<br><br>


89行目: 89行目:
strJagStudent[i].Lengthは配列の中の配列の長さ(要素数)を意味する。ここでは、配列の長さに応じて、値は1~3をとる。<br>
strJagStudent[i].Lengthは配列の中の配列の長さ(要素数)を意味する。ここでは、配列の長さに応じて、値は1~3をとる。<br>
<br>
<br>
  <source lang="c++">
  <syntaxhighlight lang="c++">
  using System;
  using System;
  using System.Collections.Generic;
  using System.Collections.Generic;
109行目: 109行目:
                                     };
                                     };
   
   
           for (int i = 0; i < student_list.Length; i++)
           for (int i = 0; i < strJagStudent.Length; i++)
           {
           {
             for (int j = 0; j < student_list[i].Length; j++)
             for (int j = 0; j < strJagStudent[i].Length; j++)
             {
             {
                 Console.Write(student_list[i][j] + ":");
                 Console.Write(strJagStudent[i][j] + ":");
             }
             }
             Console.WriteLine();
             Console.WriteLine();
121行目: 121行目:
     }
     }
  }
  }
  </source>
  </syntaxhighlight>
<br><br>
<br><br>


128行目: 128行目:
例えば、以下のようなジャグ配列を宣言することができる。<br>
例えば、以下のようなジャグ配列を宣言することができる。<br>
<br>
<br>
  <source lang="c#">
  <syntaxhighlight lang="c#">
  int[][,] jagged_array = new int[3][,]
  int[][,] jagged_array = new int[3][,]
                         {
                         {
135行目: 135行目:
                         new int[,]{ {32,53}, {7,3} }
                         new int[,]{ {32,53}, {7,3} }
                         };
                         };
  </source>
  </syntaxhighlight>
<br><br>
<br><br>


__FORCETOC__
__FORCETOC__
[[カテゴリ:C_Sharp]]
[[カテゴリ:C_Sharp]]