zoukankan      html  css  js  c++  java
  • 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(没有找到鞍点)!");

            }

        }

    }

  • 相关阅读:
    ZAB 和 Paxos 算法的联系与区别?
    Spring支持的ORM?
    解释对象/关系映射集成模块?
    哪种依赖注入方式你建议使用,构造器注入,还是 Setter方法注入?
    我们能自己写一个容器类,然后使用 for-each 循环码?
    Struts2的Action中获取request对象的几种方式?
    Chroot 特性?
    String是最基本的数据类型吗?
    @Autowired 注解?
    比较HQL、Criteria、Native-SQL这三者做查询的区别,以及应该如何进行选择?
  • 原文地址:https://www.cnblogs.com/D10304/p/15664625.html
Copyright © 2011-2022 走看看