九九矩阵

来源:互联网 发布:宝鸡市广电网络新建路 编辑:程序博客网 时间:2024/06/09 15:08

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication65
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] arr = new int[9, 9];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (i == j || i + j == 8) arr[i, j] = 1;
                    else arr[i, j] = 0;

                    Console.Write("{0} ", arr[i, j]);
                }
                Console.WriteLine();
                Console.ReadKey();
            }
        }
    }
}

0 0
原创粉丝点击