1.编写程序,建立并输出一个10*10的矩阵,该矩阵对角线元素为1,其余元素均为0。输出该数组。
代码如下:
<span style="font-family:SimSun;font-size:18px;">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 矩?阵ó1
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[10, 10];
int i, j;
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
{
if (i == j || i + j == 9)