#include<stdio.h>
int main(void)
{
int output (int years,int months);
int flag(int years);
int n,i = 1,j;
int days;
printf("Input a years:\n");
scanf("%d",&n);
do{
printf("%d Years %d Months:\n",n,i);
days = output(n,i);
for(j = 1; j <= days;++j)
{
printf("%3d",j);
if(j % 7 ==0)
printf("\n");
}
++i;
printf("\n");
}while(i < 13);
return 0;
}
int output (int years,int months)
{
int flag(int years);
int days;
if(months ==2)
{
if(flag(years))
days = 29;
else
days = 28;
}
else if(months == 1 || months == 3 || months == 5 || months == 7 ||months == 8 ||months == 10 || months == 12)
days = 31;
else
days = 30;
return days;
}
int flag(int years)
{
int result;
if(years % 4 ==0 && years % 100 !=0 || years % 400 ==0)
result = 1;
else
result = 0;
return result;
}
希望各位多多指点啊.