主题:新人求高手指点。。。。
求高手把下面的C程序改写成C++的,或者帮忙写一篇显示前后三个月的日历程序,作业在即,不胜感激
#include <stdio.h>
void getday(int year, int month)
{
int mon[] = {31,28,31,30,31,30,31,31,30,31,30,31}, total = 0, i, day;
if(year%400==0 || (year%4 == 0 && year%100!=0))
mon[1]++;
for(i = 0; i < month-1; i++)
total += mon[i];
day = (year/4 - year/400 + year*365 + total)%7;
printf("Sun Mon Tue Wed Thu Fri Sat\n");
for(i = 0; i < day; i++)
printf(" ");
for(i = 1; i <= mon[month-1]; i++)
{
if((i+day-1)%7 == 0)
printf("\n");
printf("%3d ", i);
}
printf("\n\n");
}
int main( )
{
int year, month;
scanf("%d/%d", &year, &month);
if(month == 1)
getday(year-1, 12);
else
getday(year, month-1);
getday(year, month);
getday(year, month+1);
return 0;
}
[em7][em7][em7][em7][em7][em7][em21][em21][em21][em21][em21]