zoukankan      html  css  js  c++  java
  • C#排序功能-顺便求最大值

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.Data.OleDb;
    using Microsoft.Office.Interop.Excel;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                //params 求出最大值
    
                String s = Console.ReadLine();      //设用户输入6,3,,4,5,6,7,,,8,9,2,19, 23,85, 99,,
                //s = "234,23,5,45,6,5,7,,,8,9,,0,,,5";
                getMax(Processing(s));
            }
    
            static int[] Processing(string data)
            {
    
                string[] datas = data.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                int[] arr = new int[datas.Length];
                int i = 0;
                foreach (string s in datas)
                {
                    arr[i] = Convert.ToInt32(s);
                    i++;
                }
                return arr;
            }
    
    
            static void getMax(params int[] Datas)
            {
                int tmp = 0;
                string strTmp = "";
                int j = 0;
                for (int i = 0; i < Datas.Length; i++)
                {
                    for (j = i; j < Datas.Length; j++)
                    {
                        if (Datas[i] > Datas[j])
                        {
                            tmp = Datas[i];
                            Datas[i] = Datas[j];
                            Datas[j] = tmp;
                        }
                    }
                }
                foreach (int i in Datas)
                {
                    Console.WriteLine(i);
                }
    
                Console.Read();
    
    
    
            }
        }
    }
  • 相关阅读:
    fastDFS与nginx整合2
    fastDFS分布式文件系统
    NIO编程
    Nginx正向代理与反向代理
    JAVA序列化
    FileUpload问题
    测试覆盖率实现技术
    Hutool 功能特色:
    自建右键服务器
    20191123-SWITCH后面跟的参数不能为string类型
  • 原文地址:https://www.cnblogs.com/YuanDong1314/p/8967972.html
Copyright © 2011-2022 走看看