📄 ccalendar.cpp
字号:
//#include "ccalendar.h"
//#include <iostream>
//#include <fstream>
//using namespace std;
//
//ccalendar::ccalendar(int defaultnYear)//构造函数
//{
// nYear=defaultnYear;
// if (defaultnYear==2008)
// cout<<"\t"<<char(2)<<" 成功创建对象!若无修改,默认年份为2008年."<<endl;
// else
// cout<<"\t"<<char(2)<<" 已经按照您的需求建立对象!"<<"年份为"<<nYear<<"年."<<endl;
//}
//
//ccalendar::~ccalendar(void)//析构函数
//{}
//
//void ccalendar::SetnYear(int nYear)//设置日历年份
//{
// this->nYear=nYear;
// cout<<"\t成功设置年份为"<<nYear<<"年!"<<endl;
//}
//bool ccalendar::IsRunYear(int nYear)//判断某年是否是闰年
//{
// if ((nYear%4==0&&nYear%100!=0)||(nYear%4==0&&nYear%400==0))
// {
// cout<<"\t你所查询的"<<nYear<<"年是闰年"<<endl;
// return true;
// }
// else
// {
// cout<<"\t你所查询的"<<nYear<<"年不是闰年"<<endl;
// return false;
// }
//}
//int ccalendar::m_gapday()//计算每年起始周几
//{
// m_gap=(nYear*365+(nYear-1)/4-(nYear-1)/100+(nYear-1)/400)%7;
// return m_gap;
//}
//void ccalendar::PutFile(char *FileName,bool bStyle)//将日历输出到文本文件中,true表示纵向输出
//{
//PrintCalendar(bStyle,true,FileName);
//cout<<endl<<"\t"<<char(2)<<"已经将日历输出到指定文本文件中!"<<endl;
//}
//void ccalendar::PrintCalendar(bool bStyle,bool text,char* FileName)//不同方式打印某年日历
//{
// m_gap=m_gapday();
// int boolrun;
// int n=m_gap;
// fstream filecalendar;
// filecalendar.open(FileName,ios::out);
// if (bStyle==true)
// {
// for( nMonth=1;nMonth<=12;nMonth++)
// {
// if (text)
// {
// filecalendar<<nMonth<<"月"<<endl;
// filecalendar<<"日"<<'\t'<<"一"<<'\t'<<"二"<<'\t'<<"三"<<'\t'<<"四"<<'\t'<<"五"<<'\t'<<"六"<<endl;
// }
// else
// {
// cout<<nMonth<<"月"<<endl;
// cout<<"日"<<'\t'<<"一"<<'\t'<<"二"<<'\t'<<"三"<<'\t'<<"四"<<'\t'<<"五"<<'\t'<<"六"<<endl;
// }
// for(int temp=1;temp<=n;temp++)
// {
// if (text) filecalendar<<'\t';
// else cout<<'\t';
// }
// if (bRunNian==true)
// boolrun=29;
// else boolrun=28;
// switch (nMonth)
// {
// case 1:case 3:case 5:case 7:case 8:case 10:case 12:nMonthday=31;break;
// case 4:case 6:case 9:case 11:nMonthday=30;break;
// case 2:nMonthday=boolrun;break;
// }
// for(int j=1;j<=nMonthday;j++)
// {
// if (text)
// filecalendar<<j<<'\t';
// else
// cout<<j<<'\t';
// n++;
// if (n%7==0)
// if (text)
// filecalendar<<endl;
// else
// cout<<endl;
// n=n%7;
// }
// if (text)
// {
// filecalendar<<endl; filecalendar<<endl;
// }
// else
// {
// cout<<endl;cout<<endl;
// }
// }
// filecalendar.close();
// }
// else///////////////////////////////////////////////////////横向输出
// {
// int column=1;
// n=0;
// int nMonth=1;
// if (bRunNian==true)
// boolrun=29;
// else boolrun=28;
// int nMonthday[12]={31,0,31,30,31,30,31,31,30,31,30,31};
// nMonthday[1]=boolrun;
// int over=0;
// int outday[12]={1,1,1,1,1,1,1,1,1,1,1,1};
// nMonth=1;
// do
// {
// if (column==1&&outday[nMonth-1]==1)//行末判断:空行还是返回
// {
// if ((nMonth==1)||(nMonth==5&&outday[nMonth]==1&&over==4)||(nMonth==9&&outday[nMonth]==1&&over==8))
// {
// for(int end=1;end<=3;end++)
// {
// cout<<endl;
// }
// for(int i=0;i<4;i++)
// {
// cout<<nMonth+i<<"月";
// for (int i=0;i<8;i++)
// cout<<'\t';
// }
// cout<<endl;
// for(int i=0;i<4;i++)
// {
// cout<<"日"<<'\t'<<"一"<<'\t'<<"二"<<'\t'<<"三"<<'\t'<<"四"<<'\t'<<"五"<<'\t'<<"六"<<'\t'<<'\t';
// }
// cout<<endl;
// }
// else if (nMonth>=5)
// nMonth=nMonth-4;
// }
// for(outday[nMonth-1];outday[nMonth-1]<=nMonthday[nMonth-1];)
// {
// if ((outday[nMonth-1]==1)&&(nMonth!=1)) //月初m_gap
// {
// m_gap=(m_gap+nMonthday[nMonth-2])%7;
// for(int temp=1;temp<=m_gap;temp++)
// {
// cout<<'\t';n++;
// }
// }
// if ((outday[nMonth-1]==1)&&(nMonth==1)) //年初m_gap
// {
// for(int temp=1;temp<=m_gap;temp++)
// {
// cout<<'\t';n++;
// }
// }
// cout<<outday[nMonth-1]<<'\t';n++; //输出日子
// outday[nMonth-1]++;
//
// if(outday[nMonth-1]>nMonthday[nMonth-1]) //一个月输完标记
// {
// over++;if (over==12)break;
// while (n%7!=0) //补空格
// {
// cout<<'\t';n++;
// }
// }
// if (n%7==0)
// {
// column++;cout<<'\t';
// if (column==5)
// {
// column=1;cout<<endl;
// } // 跳区
// nMonth++; break;//月份自加 并且跳出
// }
// }
// if (over==12)break;
// if ((outday[nMonth-1]>nMonthday[nMonth-1])&&((n%7)==0)) //over月补空格行
// {
// for (int i=1;i<=7;i++)
// {
// cout<<'\t';n++;
// }
// cout<<'\t';
// column++;
// if (column==5)
// {column=1;cout<<endl;}
// nMonth++;
// }
// if (nMonth==13)
// {
// if ((outday[nMonth-5]>nMonthday[nMonth-5])&&(outday[nMonth-2]>nMonthday[nMonth-2])&&(outday[nMonth-3]>nMonthday[nMonth-3])&&(outday[nMonth-4]>nMonthday[nMonth-4]))
// break;
// else nMonth-=4;
// }
// }while (over!=12);
// }
//}
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -