方法:
1、打开【文件】|【新建】|【通用模板】
2、【其他文档】|【日历向导】,使用这个模板,可以很轻松地做出一份日历来。
#include <iostream>#include <iomanip >
using namespace std
void Output(int year,int month,bool which)
{
int mon[12]={31,28,31,30,31,30,31,31,30,31,30,31}
long alldays(62)
int firstday
int i
alldays+=(year-1)*365+(year-1)/4
firstday=alldays%7
if(which)
mon[1]=29
for(i=0i<month-1i++)
firstday+=mon[i]
firstday%=7
for(i=0i<firstdayi++)
cout<<" "
for(i=1i<=mon[month-1]i++)
{
cout<<setw(7)<<i
if((firstday+i)%7==0)
cout<<endl
}
}
int main()
{
char ch
int Year
int Month
bool whichyear
step1:cout<<"Now Please input year: "
cin>>Year
cout<<"Now Please input month: "
cin>>Month
cout<<Year
if(((Year%4==0)&&(Year%100!=0))||(Year%400==0))
{
cout<<"年是闰年,天数为366天"<<endl
whichyear=1
}
else
{
cout<<"年是平年,天数为365天"<<endl
whichyear=0
}
cout<<"Mon Tues Wens thursFriSatSun"<<endl
Output(Year,Month,whichyear)
cout<<endl<<"是否继续查看y/n?"
cin>>ch
if((ch=='Y')||(ch=='y'))
goto step1
else
exit(0)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)