please have a look
#include<iostream.h>wannianli();
int getweek(int year);
int leapyear(int year);
void getdays(int year,int *p,int n);
void main()
{
int year;
cin>>year;
int a[12]={31,29,30,31,30,31,31,30,31,30,31};
int b[12]={31,28,30,31,30,31,31,30,31,30,31};
int e=leapyear(year);
if(e==1)
getdays(year,a,12);
else
getdays(year,b,12);
}
int getweek(int year)
{
int m;
m=(year+(year-1)/4-(year-1)/100+(year-1)/400)%7;
return m;
}
void getdays(int year,int *p,int n)
{cout<<"一"<<" "<<"二"<<" "<<"三"<<" "<<"四"<<" "<<"五"<<" "<<"六"<<" "<<"日"<<endl;
int count=0;
for( int i=1;i<getweek( year);i++)
{
cout<<" "<<" ";
count++;
}
for( i=0;i<=11;i++)
{
for(int j=1;j<=p[i];j++)
{
cout<<j<<" ";
count++;
if(count%7==0)
cout<<endl;
else
continue;
}
cout<<endl;
for(int k=1;k<=(count%7);i++)
{cout<<" "<<" ";
count++;
}
}
}
int leapyear(int year)
{
if((year%400==0)||((year%100!=0)&&(year%4==0)))
return 1;
else
return 0;
}
运行的时候怎么只出现两个或三个月份的日历?