读书人

用c#如何写保龄球计分程序

发布时间: 2012-09-05 15:19:35 作者: rapoo

用c#怎么写保龄球计分程序
就是 手动输入每轮的数,然后求和。

[解决办法]

C# code
 static void Main(string[] args)        {                    //int[] intArr = new int[22];            string str;            int total = 0;            for (int i = 1; i <= 22; i++)            {                Console.WriteLine("请输入第"+i+"个成绩:");                str = Console.ReadLine();                try                {                    if (int.Parse(str) > 10) { Console.WriteLine("不能大于10"); Console.ReadLine(); }                }                catch (Exception ex) {                    Console.WriteLine("不是数字"); Console.ReadLine();                }                total += int.Parse(str);                if (i == 22)                {                    Console.WriteLine("总成绩:" + total);                    Console.ReadLine();                }            }        } 

读书人网 >C#

热点推荐