我只是不想丢掉这个课堂作业
2017-10-10 16:59
281 查看
#include <iostream> #include <cstring> #include <algorithm> #include <string> using namespace std; int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; bool is_jumpyear (int n) { if (n % 400 == 0 || (n % 100 != 0 && n % 4 == 0)) return true; return false; } bool isRightYear (int y,int m,int d) { if (y <= 0) { cout << "The year must be a postive !\n"; return false; } if (m <= 0 || m > 12) { cout << "The month must between 1 and 12 \n"; return false; } if (d <= 0) { cout << "The day must greater than 0\n"; return false; } if (is_jumpyear(y)) month[2] = 29; int limit_day = month[m]; if (d > limit_day) { cout << "The day should not greater than " << limit_day << endl; return false; } return true; } int main () { ios_base :: sync_with_stdio(false); int y,m,d; while(cin >> y >> m >> d) { if (isRightYear(y, m, d)) { cout << "yes" << endl; } } return 0; }
相关文章推荐
- 无需root简单易用安卓wifi调试 这个只是一个小操作,三步: 1. 用数据线连接你的手机和电脑 2. 电脑终端执行命令: adb tcpip 5555 3. 电脑终端执行命令: adb c
- 12.25课堂笔记、作业
- 课堂作业之判断奇数偶数
- 网易面试题之 牛牛的作业薄上有一个长度为 n 的排列 A,这个排列包含了从1到n的n个数,但是因为一些原因, * 其中有一些位置(不超过 10 个)看不清了,但是牛牛记得这个数列顺序对的数量是 k,
- 2017-10-31课堂作业02
- java课堂作业(二)
- 2017-11-8课堂作业
- C++第一次课堂作业 circle
- 如果bug只是在你自己的电脑上偶尔才发生,那么这个bug必定会在客户的电脑上频繁发生
- 课堂作业-找水王
- 课堂作业1
- 11.21课堂作业-实现jQuery,DOM的增删查改
- 移动开发课堂作业1_____LayoutTest
- 课堂作业-找水王2
- 课堂作业-Bag类的实现
- 补3.11作业:书上P135的SET协议工作流程与老师课堂笔记的区别
- 课堂作业3
- 第9周作业(暂停,做设计去,不玩这个了)
- 第四次课堂作业