作业三
要求
程序
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("请输入4家店的价格");
int[] jg =new int [4];
for(int i = 0;i<jg.Length;i++)
{
Console.WriteLine("请输入第{0}家店的价格:", i + 1);
jg[i] = Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < jg.Length - 1; i++)
{
for (int j = 0; j < jg.Length - 1 - i; j++)
{
if (jg[j] > jg[j + 1])
{
int temp = jg[j];
jg[j] = jg[j + 1];
jg[j + 1] = temp;
}
}
}
Console.WriteLine("");
Console.WriteLine("最低价格是:{0}", jg[0]);
}
catch
{
Console.WriteLine("你的格式输入有误");
}
Console.ReadKey();
}
}