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

alt alt

全部评论
有帮助谢谢
1 回复 分享
发布于 2022-03-28 15:29

相关推荐

认真搞学习:这么良心的老板真少见
点赞 评论 收藏
分享
牛客83700679...:简历抄别人的,然后再投,有反馈就是简历不行,没反馈就是学历不行,多投多改只要技术不差机会总会有的
点赞 评论 收藏
分享
仁者伍敌:实习生要工作经验,工作要实习经验
点赞 评论 收藏
分享
评论
12
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务