2维数组我是用
List<List<int> >arr=new List<List<int> >()
这样来的

解决方案 »

  1.   

    /*
     * Created by SharpDevelop.
     * User: qsmy
     * Date: 2009-05-30
     * Time: 19:07
     * 
     * To change this template use Tools | Options | Coding | Edit Standard Headers.
     */
    using System;namespace yangFei
    {
    class Program
    {
    public static void Main(string[] args)
    {
    int c=1;
    int i,m,n;
    Console.Write("请输入i的值:");
    i=Convert.ToInt32(Console.ReadLine());
    for(m=0;m<=i;m++)
    {
    Console.Write("   "+c.ToString());
    for(n=1;n<=m;n++)

    {


    c=c*(m-n+1)/n;
    Console.Write("   {0}",c);

    }
    Console.WriteLine("");
    }
    Console.Write("Press any key to continue . . . ");
    Console.ReadKey(true);

    }
    }
    }
      

  2.   

    int r=int.Parse(Console.ReadLine());
                int[,] a=new int[r+1,r+1];
                int i=0;int j=0;
                for(;i<r;i++)
                {
                    j=0;
                    for(;j<=i;j++)
                    {
                        if(j==0||j==i)
                        {
                            a[i,j]=1;
                        }
                        else 
                        {
                            a[i,j]=a[i-1,j-1]+a[i-1,j];
                        }
                        Console.Write("{0} \t",a[i,j]);
                    }
                        Console.WriteLine();
                }
                Console.Read();   const int M = 7;
                int[][] yhsj = new int[M][];
                int i, j;
                for (i = 0; i < M; i++) 
                    yhsj[i] = new int[i + 1];
                for (i = 0; i < M; i++)
                {
                    yhsj[i][0] = 1;
                    yhsj[i][i] = 1;
                }
                for (i = 2; i < M; i++)
                    for (j = 1; j < i; j++)
                        yhsj[i][j] = yhsj[i - 1][j - 1] + yhsj[i - 1][j];
                for (i = 0; i < M; i++)
                {
                    Console.WriteLine();
                    for (j = 0; j <= i; j++)
                        Console.Write("{0}   ", yhsj[i][j]);
                }
                Console.Read();
      

  3.   

       static void Main(string[] args)
            {            int a,b;
                int [][] yan=new int [8][];
                for(a=0;a<yan .Length ;a++)
                {
                    yan [a]=new int [a+1];
                    yan[a][0] = 1;
                    yan[a][a] = 1;
                }
                for (a = 2; a < yan.Length; a++)
                {
                    for (b = 1; b < yan[a].Length-1; b++)
                    {
                        yan[a][b] = yan[a - 1][b - 1] + yan[a - 1][b];
                    }
                }
                for(a=0;a<yan.Length ;a++)
                {
                    for (b=0;b<yan[a].Length ;b++)
                    {
                        Console.Write("{0,5}", yan[a][b]);
                    }
                    Console.WriteLine ();
                }
                Console.Read();
            }
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Text;namespace shanjiao
    {
        class Program
        {
            static void Main(string[] args)
            {
                
                int [][]a=new int[10][];
                for (int i=1; i <a.Length; i++)  //让数组坐标从1开始
                {
                    a[i] = new int[i + 1];
                    a[i][1] = 1;             //使第一列元素值为1
                    a[i][i] = 1;            // 使对角线元素为1
                }
                for (int i = 3; i < a.Length; i++)
                {
                    for (int j = 2; j <= i - 1; j++)
                    { 
                        a[i][j] = a[i - 1][j - 1]+a[i - 1][j];
                    }
                }
                for (int i = 1; i <a.Length; i++)
                {
                    for (int j = 1; j <= i; j++)
                    { 
                        Console.Write("{0,4}", a[i][j]); 
                    }
                    Console.WriteLine();
                }
                Console.ReadLine();
        
           }
        }