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)
a[i, j] = 1;
else
a[i, j] = 0;

这篇博客介绍了如何使用C#编程实现两个矩阵操作:一是创建一个10*10的矩阵,对角线元素为1,其他元素为0,并输出;二是生成一个4*4的随机矩阵,元素在20到50之间,计算两条对角线元素之和,同时统计小于35和大于等于35的元素个数。
最低0.47元/天 解锁文章
3416

被折叠的 条评论
为什么被折叠?



