有没有大神在,帮个忙

来源:6-1 练习题目

幽织梦

2016-08-05 09:30

有木有哪位大神可以帮我写个程序,即使随意输入一个数组,然后把每个数组中的数字的各个位数按照升序排列,再把这个数组排序后输出最大的数,比如输入(312,56,87),

然后

输出(56,78,123,最大的

数位123

写回答 关注

1回答

  • Arsennnic
    2016-08-05 19:58:22

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;


    namespace ConsoleApplication1

    {

        class Program

        {

            static void Main(string[] args)

            {

                int N = 3, temp;

                int[] arr = new int[N];

                for (int i = 0; i < N; i++)

                {

                    arr[i] = int.Parse(Console.ReadLine());

                }

                for (int i = 0; i < N - 1; i++)

                {

                    for (int j = 0; j < N - i - 1; j++)

                    {

                        if (arr[j + 1] < arr[j])

                        {

                            temp = arr[j];

                            arr[j] = arr[j + 1];

                            arr[j + 1] = temp;

                        }

                    }

                }

                for (int i = 0; i < N; i++)

                {

                    Console.Write(arr[i]);

                }

                Console.Write("最大的数为{0}", arr[N - 1]);

            }

        }

    }


C#开发轻松入门

本门课程是C#语言的入门教程,将带你轻松入门.NET开发

254751 学习 · 1459 问题

查看课程

相似问题