美文网首页
C#第十一次作业2

C#第十一次作业2

作者: 亻尔亻也 | 来源:发表于2018-12-06 20:25 被阅读0次

    完成以下要求:

    int[] shuru = new int[6];

                int max = 0;

                try

                {

                    for (int i = 0; i < shuru.Length; i++)

                    {

                        Console.WriteLine("请输入第{0}个整数",i+1);

                        shuru[i] = Convert.ToInt32(Console.ReadLine());

                    }

                    for (int i = 0; i < shuru.Length-1; i++)

                    {

                        for (int j = 0; j < shuru.Length-1-i; j++)

                        {

                            if (shuru[j]>shuru[j+1])

                            {

                                max = shuru[j];

                                shuru[j] = shuru[j+1];

                                shuru[j+1] = max;

                            }

                        }

                    }

                    for (int i = 0; i < shuru.Length; i++)

                    {

                        Console.Write("{0}\t",shuru[i]);

                    }

                }

                catch

                {

                    Console.WriteLine("输入有误请重新输入");

                }

                Console.ReadKey();

    相关文章

      网友评论

          本文标题:C#第十一次作业2

          本文链接:https://www.haomeiwen.com/subject/etdacqtx.html