#代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("输入四家店的价格");
try
{
int[] jia = new int[4];
Console.WriteLine("第一家店价格:");
jia[0] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("第二家店价格:");
jia[1] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("第三家店价格:");
jia[2] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("第四家店价格:");
jia[3] = Convert.ToInt32(Console.ReadLine());
int a = 100000000;
for (int i = 0; i < jia.Length; i++)
{
if (jia[i] < a)
{
a = jia[i];
}
}
Console.WriteLine("最小值是{0}", a);
}
catch
{
Console.WriteLine("您输入有误");
}
Console.ReadKey();
}
}
}
#效果
网友评论