万年历
来源:互联网 发布:慧眼文字识别软件 编辑:程序博客网 时间:2024/04/29 07:42
#include<iostream>using namespace std;int isLeapYear(int year){if (year % 100 == 0 && year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)){return 1;}elsereturn 0;}int monthDays(int year,int month){int n[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };if (isLeapYear(year))n[1] = 29;return n[month - 1];}int dayNumber(int year,int month){int c,i,s = 0;int n[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };if (isLeapYear(year))n[1] = 29;for (i = 0; i<month - 1; i++){s = n[i] + s;}c = s + 1;return c;}int week(int year, int month, int c){int s;s = (year - 1 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400 + c) % 7;return s;}int main(){int year, month;int mon,d,k;while (cin >> year >> month){d=dayNumber(year,month);mon=monthDays(year,month);k=week(year, month, d);cout << "日" << '\t' << "一" << '\t' << "二" << '\t' << "三" << '\t' << "四" << '\t' << "五" << '\t' << "六" << endl;for (int i = 1; i <= mon; i++){if (i == 1){for (int j = 0; j<k; j++){cout << '\t';}}cout << i << '\t';if ((i + k) % 7 == 0){cout << endl;}}cout << endl << endl;}return 0;}
0 0
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- 万年历
- localhost无法登录
- Platinum SDK 使用 NDK 编译
- Android Service更新UI的方法之AIDL
- Struts 国际化 i18n 的配置
- 散列表(哈希表)之链接法浅谈
- 万年历
- leetcode刷题,总结,记录 ,备忘 172
- java集合框架——接口图+类图+遗留类图
- php单例模式学习
- POJ 3009 Curling 2.0(dfs)
- UCOSIII-任务管理(上)
- HDU 3435 A new Graph Game KM算法
- iOS_开发中遇到的那些问题_6
- 分类与回归的区别