c#题解 | #赢的次数#
大家一起加油啊!题解代码附下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Program {
public static void Main() {
//设置变量保存分数
int score;
//异常捕获,排除错误字符
a: try
{
score = Convert.ToInt32(Console.ReadLine());
}
catch (Exception)
{
//输入不合法字符时,跳回重新输入
goto a;
}
//判断的分数的奇偶
if (score % 2 == 0)
{
//基数时
Console.WriteLine((int)score / 2);
}
else
{
//偶数时
Console.WriteLine((int)score / 2 + " " + ((int)score / 2 + 1));
}
}
}