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(没有找到鞍点)!");

            }

        }

    }

  • 相关阅读:
    Jar依赖很多,找不到重复的包??好工具来帮助您
    BHP编译器教程
    MySvn--一个简单单机svn程序源码-delphi开发
    delphi也可以使用C语言脚本 --Picoc脚本语言
    sqlserver,mysql,oracle通用的模拟和改进的全文搜索算法
    EhReport ,CReport改进版本,再次改进 ,V1.31
    Robot Framework(3)——RIDE工具详解
    Robot Framework(2)——简单运行案例
    Robot Framework(1)——环境搭建及安装
    Jenkins(1)—— 部署安装
  • 原文地址:https://www.cnblogs.com/D10304/p/15664625.html
Copyright © 2011-2022 走看看