• C#学习五


    编写程序,找一找一个二维数组中的鞍点(即该位置上的元素值在行中最大,在该

    列上最小。有可能数组没有鞍点)。要求: 

    u u 二维数组的大小、数组元素的值在运行时输入;

    u 程序有友好的提示信息。

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    namespace _20153236_sy1_3

    {

        class Program

        {

            static void Main(string[] args)

            {

                int[,] nos = new int[3, 4];

                int xMaxIndex = 0;

                bool isFind = false;

                for (int i = 0; i < nos.Rank; i++)

                {

                    for (int j = 1; j < nos.Length / (nos.Rank + 1); j++)

                    {

                        if (nos[i, j] > nos[i, j - 1])

                            xMaxIndex = j;

                    }

                    bool isMin = true;

                    for (int k = 0; k < nos.Rank; k++)

                    {

                        if (k == i)

                            continue;

                        if (nos[k, xMaxIndex] < nos[i, xMaxIndex])

                            isMin = false;

                    }

                    if (isMin)

                    {

                        Console.Write("[{0},{1}]={2} 是鞍点!", i, xMaxIndex, nos[i, xMaxIndex]);

                        isFind = true;

                    }

                }

                if (!isFind)

                    Console.Write("Not Find(没有找到鞍点)!");

            }

        }

    }

  • 相关阅读:
    2021 6 3
    2021 5月 读书笔记
    2021 6 1
    第十三周 2021.05.30
    spring security permitAll不生效
    springboot配置jpa提示Unable to resolve name [mysql] as strategy
    element el-form-item el-input宽度设置
    vue+element表格中使用render函数(if判断处理)
    elementui移除tab报Avoided redundant navigation to current location: ***
    el-dropdown-item添加@click不生效
  • 原文地址:https://www.cnblogs.com/D10304/p/15664625.html
Copyright © 2020-2023  润新知