#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main()
{
int i,year,firstday,k,j,number,a;
char b;
b=' ';
cin>>year;
firstday=(year-2010)%7+5;
if(firstday<=0)
{
firstday=firstday+7;
}
if(firstday>7)
firstday=firstday-7;
for(i=1;i<=12;i++)
{
j=1;
if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
number=31;
else if(i==2)
{
if((year%4==0&&year%100!=0)||year%400==0)
number=29;
else
number=28;
}
else
number=30;
cout<<setw(2)<<i;
cout<<setw(6)<<"one"
<<setw(6)<<"two"
<<setw(6)<<"three"
<<setw(6)<<"four"
<<setw(6)<<"five"
<<setw(6)<<"six"
<<setw(6)<<"seven"<<endl;;
k=1;
while(k!=firstday)
{
cout<<setw(6)<<b;
k++;
}
while(j<=number)
{
for(;k<=7;k++)
{
if(j==number+1)
break;
cout<<setw(6)<<j;
k++;
j++;
a=k;
}
k=1;
cout<<endl;
}
if(a==8)
firstday=1;
else
firstday=a;
}
}
我写了一个输出日历的程序,不知道怎么老出错