编程题#4:Tomorrow never knows?

博客讲述了作者在编程题中忽视了闰日逻辑,通过测试用例发现错误的经验。强调了测试对于避免漏洞的重要性,并提供了几个测试用例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

编程题#4:Tomorrow never knows?以玩家的心态测试

平时没有发布自己代码的习惯,但是今天这是个血的教训啊!!看了好久也没找出问题,然后就决定使用测试用例测试,结果还是忘了一种可能..那就是,2014-02-29,只顾着写闰年的逻辑,过年的逻辑,万万没想到…居然忘了闰日的逻辑…

总结原因就是,一只踩着认为有坑的地方不放,结果原来一直在坑里…

#include <iostream>
#include <iomanip>
#include <string.h>
#include <stdio.h>
using namespace std;

bool IsLeapYear( int year ){
    bool isLeap = false;
    if(year % 100 == 0 && year % 400 == 0
#--------------------------- # Hexo Theme Fluid # Author: Fluid-dev # Github: https://github.com/fluid-dev/hexo-theme-fluid # # 配置指南: https://hexo.fluid-dev.com/docs/guide/ # 你可以从指南中获得更详细的说明 # # Guide: https://hexo.fluid-dev.com/docs/en/guide/ # You can get more detailed help from the guide #--------------------------- #--------------------------- # 全局 # Global #--------------------------- theme: fluid # 指定主题 language: zh-CN # 指定语言,会影响主题显示的语言,按需修改 # 用于浏览器标签的图标 # Icon for browser tab favicon: /img/fluid.png # 用于苹果设备的图标 # Icon for Apple touch apple_touch_icon: /img/fluid.png # 浏览器标签页中的标题分隔符,效果:文章名 - 站点名 # Title separator in browser tab, eg: article - site tab_title_separator: " - " # 强制所有链接升级为 HTTPS(适用于图片等资源出现 HTTP 混入报错) # Force all links to be HTTPS (applicable to HTTP mixed error) force_https: false # 代码块的增强配置 # Enhancements to code blocks code: # 是否开启复制代码的按钮 # Enable copy code button copy_btn: true # 代码语言 # Code language language: enable: true default: "TEXT" # 代码高亮 # Code highlight highlight: enable: true # 代码块是否显示行号 # If true, the code block display line numbers line_number: true # 实现高亮的库,对应下面的设置 # Highlight library # Options: highlightjs | prismjs lib: "highlightjs" highlightjs: # 在链接中挑选 style 填入 # Select a style in the link # See: https://highlightjs.org/demo/ style: "github gist" style_dark: "dark" prismjs: # 在下方链接页面右侧的圆形按钮挑选 style 填入,也可以直接填入 css 链接 # Select the style button on the right side of the link page, you can also set the CSS link # See: https://prismjs.com/ style: "default" style_dark: "tomorrow night" # 设为 true 高亮将本地静态生成(但只支持部分 prismjs 插件),设为 false 高亮将在浏览器通过 js 生成 # If true, it will be generated locally (but some prismjs plugins are not supported). If false, it will be generated via JS in the browser preprocess: true # 一些好玩的功能 # Some fun features fun_features: # 为 subtitle 添加打字机效果 # Typi
最新发布
03-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值