zoukankan      html  css  js  c++  java
  • 二维数组、齿形数组和游长变元表

    实例学习,代码如下:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace TwoDimensionArray
    {
        class Program
        {
            public static void OutputArray(int[,] array)
            {
                for (int i = 0; i < array.GetLength(0); i++)
                {
                    for (int j = 0; j < array.GetLength(1); j++)
                    {
                        Console.Write("{0}", array[i, j]);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
    
            public static void OutputJaggedArray(int[][] array)
            {
                foreach (var row in array)
                {
                    foreach (var element in row)
                    {
                        Console.Write("{0}", element);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
    
            public static double ParamsArray(params double[] param)
            {
                double total = 0.0;
                foreach (var element in param)
                {
                    total += element;
                }
                return total;
            }
    
            static void Main(string[] args)
            {
                int[,] rectangular = { { 1, 2, 3 }, { 4, 5, 6 } };
                int[][] jagged ={new int[]{1,2},
                                 new int[]{3},
                                 new int[]{4,5,6}};
                OutputArray(rectangular);
                OutputJaggedArray(jagged);
    
                double[] paraArray = new double[] { 1, 2, 3 };
                Console.Write("{0}
    ", ParamsArray(paraArray));
    
                Console.ReadLine();
            }
        }
    }

    输出结果如下:

    image

  • 相关阅读:
    转:神经网络入门
    转:Webkit Flex伸缩盒模型属性备忘
    css3 display:-webkit-box
    display:inline和display:block及html常用标签
    display
    weui flex 分布
    图片、字体、iconfont矢量图
    flex weui列表demo
    方法调用
    C#多线程之Task
  • 原文地址:https://www.cnblogs.com/shawnzhou/p/3321914.html
Copyright © 2011-2022 走看看