第十一次作业第一题

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{

            int[] nums = new int[4];
          
            int money = 0;
            Console.WriteLine("请输入4家店的价格");

            for (int i = 0; i <nums.Length; i++)
            {
                Console.Write("第{0}店的价格:", i + 1);
               nums[i] = Convert.ToInt32(Console.ReadLine());
            }
            for (int i = 0; i <nums.Length - 1; i++)
            {
                if (nums[i] < nums[i + 1])
                {
                   money =nums[i];
                    nums[i +1] =nums[i];
                }
                else
                {
                    money  = nums[i + 1];
                }
            }
            
            Console.WriteLine("最低价格是:{0}", money);
        }
        catch
        {
            Console.WriteLine("你输入的格式有误");
        }
        Console.ReadKey();
    }
}

}


image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 7,600评论 0 3
  • 代码 using System;using System.Collections.Generic;using Sy...
    孤独是种安全感_b7bf阅读 1,319评论 0 0
  • 代码 namespace 第十一次作业第一题{class Program{static void Main(str...
    皮皮虾_98e9阅读 1,001评论 0 0
  • 嗯,刚做了到misc题(bugku里的多种方法解决),这里记一下,怕忘了。 下载后发现是一个exe文件,改一下后缀...
    Hf1dw阅读 2,372评论 0 0
  • 由于端午节当天要去学校,提前一天回外婆家吃饭。 外婆家比较近,逢年过节爸爸家那边没有饭局的话都会回来吃...
    L_0925阅读 4,987评论 0 0