首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2012-09-05 
用c#怎么写保龄球计分程序就是 手动输入每轮的数,然后求和。[解决办法]C# code static void Main(string[]

用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();                }            }        } 

热点排行