首頁  >  文章  >  後端開發  >  C# 中的雙精度數組?

C# 中的雙精度數組?

WBOY
WBOY轉載
2023-09-10 16:53:02999瀏覽

C# 中的双精度数组?

C# 中的陣列陣列稱為鋸齒陣列。若要宣告交錯數組,請使用雙精確度 [ ][ ]。

現在讓我們宣告它們-

int [][] marks;

現在,讓我們初始化它,其中標記是5 個整數的陣列-

int[][] marks = new int[][]{new int[]{ 90,95 },new int[]{ 89,94 }, new int[]{ 78,87 },new int[]{ 76, 68 }, new
int[]{ 98, 91 } };

Example

#讓我們現在來看看C#中關於鋸齒數組的完整範例,並學習如何實現它−

實時演示

using System;
namespace MyApplication {
   class MyDemoClass {
      static void Main(string[] args) {
         int i, j;
         /* jagged array of 5 array of integers */
         int[][] marks = new int[][]{new int[]{90,95},new int[]{89,94}, new int[]{78,87},new int[]{ 76, 68 },
         new int[]{ 98, 91}};

         for (i = 0; i < 5; i++) {
            for (j = 0; j < 2; j++) {
               Console.WriteLine("marks[{0}][{1}] = {2}", i, j, marks[i][j]);
            }
         }
         Console.ReadKey();
      }
   }
}

輸出

marks[0][0] = 90
marks[0][1] = 95
marks[1][0] = 89
marks[1][1] = 94
marks[2][0] = 78
marks[2][1] = 87
marks[3][0] = 76
marks[3][1] = 68
marks[4][0] = 98
marks[4][1] = 91
#

以上是C# 中的雙精度數組?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除