#include
#include
#include
int HowManyDays(int year ,int month);
int DayOfWeek(int year );
void show();
int main()
{
int year ;
cout<<"请输入年份:"<
static int j1=1;
static int j2=1;
static int j3=1;
int weekday=DayOfWeek(year);
for(int i=0;i<4;i++)
{
show();
int n = 0;
int k = 0;
int m = 0;
while(1)
{
while(1)
{
int _month=3*i+1;
int Days=HowManyDays(year, _month);
for( j1 = n+1;j1
if(weekday==0)
cout<
if(j1
cout<
n++;
if(n%7 == 0)
break;
}
break;
}
while(1)
{
int _month=3*i+2;
int Days=HowManyDays(year,_month);
for( j2 = k+1;j2
if(weekday==0)
cout<
else{
if(j2
cout<
k++;
if(k%7==0)
break;
}
break;
}
while(1)
{
int _month=3*i+3;
int Days=HowManyDays(year,_month);
for( j3 = m+1;j3
if(weekday==0)
cout<
else{
if(j3
cout<
m++;
if(m%7==0)
{
cout<
}
}
break;
}
int _month=3*i+3;
int Days=HowManyDays(year,_month);
if(j3>=weekday+Days+1)
break;
}
}
getch();
return 0;
}
int HowManyDays(int year ,int month) //计算一个月有多少天
{
int days;
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
return days=31;
else if(month==2){
if(year%4==0&&year%100!=0||year%400==0)
return days=29;
else return days=28;
}
else
return days=30;
}
int DayOfWeek(int year ) //判断星期几
{
int i ;
int _month[12];
for(i = 0; i < 12; i++)
_month[i]=HowManyDays(year,i);
int weekday=0;
weekday = (year-1+(year-1-1)/4)%7;
return weekday;
}
void show()
{
for(int j=1;j<=3;j++)
{
static int month=1;
cout<
cout<
month++;
}
for(int k=1;k<=3;k++)
{
cout<<"-----------------------"<
{
cout<
}
}
for(int l=1;l<=3;l++)
{
cout<
{
cout<
}
}
for(int m=1;m<=3;m++)
{
cout<<"-----------------------"<
{
cout<
}
}
}
#include
#include
void main()
{
int y,m,j,c,s,num,day;//y是年,m是月,j是二月多少天
cout<<"****************************初步万年历[作者:砖头]******************************";
loop:cout<<"\n\n"<<"请输入须知年月:";
cin>>y>>m;
if(y<1900||y>2061)
{
cout<<"请输入1900年~2061年之间的日期";
goto loop;
}
if(y%4==0&&y%100!=0||y%400==0)//a为二月的天数
j=29;
else
j=28;
switch(m)
{
case 2:day=j;break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:day=31;break;
case 4:
case 6:
case 9:
case 11:day=30;break;
}//day是求出当月有多少天
c=0;
switch(m-1)
{
case 12:c+=31;
case 11:c+=30;
case 10:c+=31;
case 9:c+=30;
case 8:c+=31;
case 7:c+=31;
case 6:c+=30;
case 5:c+=31;
case 4:c+=30;
case 3:c+=31;
case 2:c+=j;
case 1:c+=31;
}//c+1求出每月一号是本年的第多少天
s=y-1+(y-1)/4-(y-1)/100+(y-1)/400+(c+1);
num=s%7;//求出星期几
cout<<'\n'<<" 日 一 二 三 四 五 六"<<"\n\n";
for(int k=1;k<=num;k++)
cout<<" ";
for(int b=1;b<=day;b++)
{
cout<
cout<<"\n\n";
}
cout<<'\n'<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
goto loop;
}
#include
using namespace std;
int main()
{
int year,day;
int year_first_day, month_first_day[12];
int index,count1,count2,total[12],yearnum;
int month_day[2][12]={31,28,31,30,31,30,31,31,30,31,30,31,
31,29,31,30,31,30,31,31,30,31,30,31};
cout<<"请输入一个年份:"<
year_first_day=(year+(year-1)/4-(year-1)/100+(year-1)/400)%7;
cout<<"-----------------------------------------------------------------------"<
if((year%4==0 && year%100 !=0) || (year%400==0))
{
month_first_day[0]=year_first_day;
total[0]=month_first_day[0];
for(index=1;index<12;index++)
{
total[index]=total[index-1]+month_day[1][index-1];
month_first_day[index]=total[index]%7;
}
yearnum=1;
}
else
{
month_first_day[0]=year_first_day;
total[0]=month_first_day[0];
for(index=1;index<12;index++)
{
total[index]=total[index-1]+month_day[0][index-1];
month_first_day[index]=total[index]%7;
}
yearnum=0;
}
for(index=0;index<12;index++)
{
day=1;
cout<
for(count1=0;count1<=(month_first_day[index]+month_day[yearnum][index])/7+1;count1++)
{
for(count2=0;count2<7;count2++)
{
if(month_first_day[index]==0 )
{
if(day<=month_day[yearnum][index])
{
cout<
}
}
else
{
cout<<"\t";
month_first_day[index]--;
}
}
cout<<"\n";
}
cout<<"------------------------------------------------------"<
cin>>year;
return 0;
}
呵呵,命令行输入 cal -y 2008 就可以了