2018-12-05第二题
2018-12-05 本文已影响0人
额丶丶丶
效果
2018-12-05第二题代码
double[] myarr = new double[5];
double zg = 0;
Console.WriteLine("请输入会员本日的消费记录");
try
{
for (int i = 0; i < myarr.Length; i++)
{
Console.Write("请输入第{0}笔购物金额:", i+1);
myarr[i] = Convert.ToInt32(Console.ReadLine());
zg += myarr[i];
}
Console.WriteLine("序号 金额(元)");
for (int i = 0; i < myarr.Length; i++)
{
Console.WriteLine("{0} {1}", i + 1, myarr[i]);
}
Console.WriteLine("总金额 {0}", zg);
}
catch
{
Console.WriteLine("输入格式错误");
}
Console.ReadKey();