这是C++课程设计作业(至少要200行)可是我补不齐了。跪求各位大神帮忙补一下。补到接近200行就行了,要是哪位好心的话,再把你们补上的过程给小弟解释一下,小弟是初学者。很多问题都不是多会的。 跪谢啊啊!
急求啊,过了明天就要交的。
#include<stdio.h>
void PrintMonthCalender(int startDay,int days);/*函数原型*/
int GetWeekDay(int year,int month);/*函数原型*/
int GetMonthDays(int year,int month);/*函数原型*/
main()
{
int month,year;/*定义变量*/
printf("input the year and month<YYYY-MM>:");
scanf("%d-%d",&year,&month);/*读入变量*/
printf("\t\t\t%d-%d\n",year,month);
printf("Sun.\tMon.\tTue.\tWed.\tThu.\tFri.\tSat.\n");/*打印日历表头*/
PrintMonthCalender(GetWeekDay(year,month),GetMonthDays(year,month));/*调用函数子程序,打印出某年某月日历*/
return 0;
}
/*定义打印日历子程序*/
void PrintMonthCalender(int startDay,int days)
{
int k=0,n=1;
while(k<startDay)
{
printf(" \t");
k++;
}
if(k==startDay&&k!=6)
{
printf("%d\t",n);
k++;
n++;
}
else if(k==startDay&&k==6)
{
printf("%d\n",n);
k++;
n++;
}
while(n<days)
{
if(k%7==6)
{
printf("%d\n",n);
k++;
n++;
}
else
{
printf("%d\t",n);
k++;
n++;
}
}
if(n=days)
{
printf("%d\n",n);
n++;
}
}
/*定义求某月一号为周几子程序*/
int GetWeekDay(int year,int month)
{
int GetMonthDays(int year,int month);
int n,WeekDay,days;
days=(year-1)*365+(year-1)/400+(year-1)/4-(year-1)/100;
for(n=1;n<month;++n)
days=days+GetMonthDays(year,n);
WeekDay=(days+1)%7;
return WeekDay;
}
/*定义求某年某月的天数子程序*/
int GetMonthDays(int year,int month)
{
int MonthDays;
if((year%4==0&&year%100!=0)||year%400==0)
{
if(month==4||month==6||month==9||month==11)
MonthDays=30;
else if(month==2)
MonthDays=29;
else
MonthDays=31;
}
else
{
if(month==4||month==6||month==9||month==11)
MonthDays=30;
else if(month==2)
MonthDays=28;
else
MonthDays=31;
}
return MonthDays;
}