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