打印日历每行三个月份源代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
int msOfWeek, int msDays, int mtOfWeek, int mtDays, int hang);
int zhouji(int year, int month, int day);
int totaldays(int year, int month, int day);
int main()
else
{
printf(" ");
}
}
}
printf(" ");
if (msDays - msDay > 6)
{
printf("%-2d %-2d %-2d %-2d %-2d %-2d %-3d ", msDay, msDay + 1, msDay + 2,
msDay + 3, msDay + 4, msDay + 5, msDay + 6);
{
int year;
printf("测绘一班李永强提醒您请输入你需要的年份:");
scanf("%d",&year);
PrintCalendar(year);
return 0;
}
int zhouji(int year, int month, int day)
{
int i;
i= ((year - 1) + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400 + totaldays(year, month, day)) % 7;
{
printf("%-2d %-2d %-2d %-2d %-2d %-2d %-3d ", mtDay, mtDay + 1, mtDay + 2,
mtDay + 3, mtDay + 4, mtDay + 5, mtDay + 6);
mtDay += 7;
printf(" ");
}
else
{
for (j = 0; j < 7; ++j)
break;
case 4:
mfOfWeek = zhouji(year,10, 1);
mfDays = 31;
msOfWeek = zhouji(year, 11, 1);
msDays = 30;
mtOfWeek = zhouji(year, 12, 1);
mtDays = 31;
PrintOneQuarter(year, mfOfWeek, mfDays, msOfWeek, msDays, mtOfWeek, mtDays, hang);
mfDay, mfDay + 1, mfDay + 2, mfDay + 3, mfDay + 4, mfDay
+ 5, mfDay + 6, msDay, msDay + 1, msDay + 2, msDay
+ 3, msDay + 4, msDay + 5, msDay + 6, mtDay, mtDay
{
if (month > 2)
{
++days;
}
}
return days;
}
void PrintOneQuarter(int year, int mfOfWeek, int mfDays, int msOfWeek,
int msDays, int mtOfWeek, int mtDays, int hang)
break;
default:
break;
}
}
void PrintCalendar(int year)
{
int i;
for (i = 0; i < 4; ++i)
{
switch (i)
{
case 0:
printf("一月二月三月\n");
printf( "-------------------- -------------------- --------------------\n");
case 4:days = 90 + day;break;
case 5:days = 120 + day;break;
case 6:days = 151 + day;break;
case 7:days = 181 + day;break;
case 8:days = 212 + day;break;
case 9:days = 243 + day;break;
printf( "日一二三四五六日一二三四五六日一二三四五六\n");
PrintCommonCalendar(year, 4);
break;
default: break;
}
}
}
msDay += 7;
printf(" ");
}
else
{
for (j = 0; j < 7; ++j)
{
if (msDay <= msDays)
{
printf("%-2d ", msDay++);
} else
{
printf(" ");
}
}
}
printf(" ");
if (mtDays - mtDay > 6)
{
if (mtDay <= mtDays)
{
printf("%-2d ", mtDay++);
}else
{
printf(" ");
}
}
}
printf(" ");
}
printf("\n");
}
void PrintCommonCalendar(int year, int hang)
{
int mfOfWeek, mfDays;
+ 1, mtDay + 2, mtDay + 3, mtDay + 4, mtDay + 5,
mtDay + 6);
mfDay += 7;
msDay += 7;
mtDay += 7;
continue;
}
if (mfDays - mfDay > 6)
{
printf("\n%-2d %-2d %-2d %-2d %-2d %-2d %-3d ", mfDay, mfDay + 1, mfDay
for(h=0;h<msOfWeek;h++)
printf(" ");
for (j = msOfWeek; j < 7; ++j)
{
printf("%-2d ", msDay);
msDay++;
}
printf(" ");
if (mtOfWeek > 0)
for(h=0;h<mtOfWeek;h++)
printf( "日一二三四五六日一二三四五六日一二三四五六\n");
PrintCommonCalendar(year, 1);
break;
case 1:
printf("四月五月六月\n");
printf("-------------------- -------------------- --------------------\n");
printf( "日一二三四五六日一二三四五六日一二三四五六\n");
PrintCommonCalendar(year, 2);
break;
case 2:
printf( "七月八月九月\n");
printf( "-------------------- -------------------- --------------------\n");
mfDays = 31;
msOfWeek = zhouji(year, 8, 1);
msDays = 31;
mtOfWeek = zhouji(year, 9, 1);
mtDays = 30;
PrintOneQuarter(year, mfOfWeek, mfDays, msOfWeek, msDays, mtOfWeek, mtDays,hang);
msDays = 31;
mtOfWeek = zhouji(year, 6, 1);
mtDays = 30;
PrintOneQuarter(year, mfOfWeek, mfDays, msOfWeek, msDays, mtOfWeek, mtDays,hang);
break;
case 3:
mfOfWeek = zhouji(year, 7, 1);
#include<stdio.h>
#include <string.h>
void PrintCalendar(int year) ;
void PrintCommonCalendar(int year, int hang);
void PrintOneQuarter(int year, int mfOfWeek, int mfDays,
{
int mfDay = 1, msDay = 1, mtDay = 1;
int i, j,h;
if (hang == 1)
{
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
msDays = 29;
}
for (i = 0; i < 6; ++i)
+ 2, mfDay + 3, mfDay + 4, mfDay + 5, mfDay + 6);
mfDay += 7;
}
else
{ printf(" \n");
for (j = 0; j < 7; ++j)
{
if (mfDay <= mfDays)
printf("%-2d ", mfDay++);
int msOfWeek, msDays;
int mtOfWeek, mtDays;
switch (hang)
{
casBaidu Nhomakorabea 1:
mfOfWeek = zhouji(year, 1, 1);
mfDays = 31;
msOfWeek = zhouji(year, 2, 1);
msDays = 28;
mtOfWeek = zhouji(year, 3, 1);
{
if (i == 0)
{
if (mfOfWeek > 0)
for(h=0;h<mfOfWeek;h++)
printf(" ");
for (j = mfOfWeek; j < 7; ++j)
{
printf("%2d ", mfDay);
mfDay++;
}
printf(" ");
if (msOfWeek > 0)
mtDays = 31;
PrintOneQuarter(year, mfOfWeek, mfDays, msOfWeek, msDays, mtOfWeek, mtDays, hang);
break;
case 2:
mfOfWeek = zhouji(year, 4, 1);
mfDays = 30;
msOfWeek = zhouji(year, 5, 1);
printf( "日一二三四五六日一二三四五六日一二三四五六\n");
PrintCommonCalendar(year, 3);
break;
case 3:
printf( "十月十一月十二月\n");
printf( "-------------------- -------------------- --------------------\n");
printf(" ");
for (j = mtOfWeek; j < 7; ++j)
{
printf("%-2d ", mtDay);
mtDay++;
}
printf(" ");
continue;
}
if (i < 4)
{
printf(
"\n%-2d %-2d %-2d %-2d %-2d %-2d %-3d %-2d %-2d %-2d %-2d %-2d %-2d %-3d %-2d %-2d %-2d %-2d %-2d %-2d %-3d",
return i;
}
int totaldays(int year, int month, int day)
{
int days = 0;
switch (month)
{
case 1:days = day;break;
case 2:days = 31 + day;break;
case 3:days = 59 + day;break;
case 10:days = 273 + day;break;
case 11:days = 304 + day;break;
case 12:days = 334 + day;break;
default:break;
}
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
int zhouji(int year, int month, int day);
int totaldays(int year, int month, int day);
int main()
else
{
printf(" ");
}
}
}
printf(" ");
if (msDays - msDay > 6)
{
printf("%-2d %-2d %-2d %-2d %-2d %-2d %-3d ", msDay, msDay + 1, msDay + 2,
msDay + 3, msDay + 4, msDay + 5, msDay + 6);
{
int year;
printf("测绘一班李永强提醒您请输入你需要的年份:");
scanf("%d",&year);
PrintCalendar(year);
return 0;
}
int zhouji(int year, int month, int day)
{
int i;
i= ((year - 1) + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400 + totaldays(year, month, day)) % 7;
{
printf("%-2d %-2d %-2d %-2d %-2d %-2d %-3d ", mtDay, mtDay + 1, mtDay + 2,
mtDay + 3, mtDay + 4, mtDay + 5, mtDay + 6);
mtDay += 7;
printf(" ");
}
else
{
for (j = 0; j < 7; ++j)
break;
case 4:
mfOfWeek = zhouji(year,10, 1);
mfDays = 31;
msOfWeek = zhouji(year, 11, 1);
msDays = 30;
mtOfWeek = zhouji(year, 12, 1);
mtDays = 31;
PrintOneQuarter(year, mfOfWeek, mfDays, msOfWeek, msDays, mtOfWeek, mtDays, hang);
mfDay, mfDay + 1, mfDay + 2, mfDay + 3, mfDay + 4, mfDay
+ 5, mfDay + 6, msDay, msDay + 1, msDay + 2, msDay
+ 3, msDay + 4, msDay + 5, msDay + 6, mtDay, mtDay
{
if (month > 2)
{
++days;
}
}
return days;
}
void PrintOneQuarter(int year, int mfOfWeek, int mfDays, int msOfWeek,
int msDays, int mtOfWeek, int mtDays, int hang)
break;
default:
break;
}
}
void PrintCalendar(int year)
{
int i;
for (i = 0; i < 4; ++i)
{
switch (i)
{
case 0:
printf("一月二月三月\n");
printf( "-------------------- -------------------- --------------------\n");
case 4:days = 90 + day;break;
case 5:days = 120 + day;break;
case 6:days = 151 + day;break;
case 7:days = 181 + day;break;
case 8:days = 212 + day;break;
case 9:days = 243 + day;break;
printf( "日一二三四五六日一二三四五六日一二三四五六\n");
PrintCommonCalendar(year, 4);
break;
default: break;
}
}
}
msDay += 7;
printf(" ");
}
else
{
for (j = 0; j < 7; ++j)
{
if (msDay <= msDays)
{
printf("%-2d ", msDay++);
} else
{
printf(" ");
}
}
}
printf(" ");
if (mtDays - mtDay > 6)
{
if (mtDay <= mtDays)
{
printf("%-2d ", mtDay++);
}else
{
printf(" ");
}
}
}
printf(" ");
}
printf("\n");
}
void PrintCommonCalendar(int year, int hang)
{
int mfOfWeek, mfDays;
+ 1, mtDay + 2, mtDay + 3, mtDay + 4, mtDay + 5,
mtDay + 6);
mfDay += 7;
msDay += 7;
mtDay += 7;
continue;
}
if (mfDays - mfDay > 6)
{
printf("\n%-2d %-2d %-2d %-2d %-2d %-2d %-3d ", mfDay, mfDay + 1, mfDay
for(h=0;h<msOfWeek;h++)
printf(" ");
for (j = msOfWeek; j < 7; ++j)
{
printf("%-2d ", msDay);
msDay++;
}
printf(" ");
if (mtOfWeek > 0)
for(h=0;h<mtOfWeek;h++)
printf( "日一二三四五六日一二三四五六日一二三四五六\n");
PrintCommonCalendar(year, 1);
break;
case 1:
printf("四月五月六月\n");
printf("-------------------- -------------------- --------------------\n");
printf( "日一二三四五六日一二三四五六日一二三四五六\n");
PrintCommonCalendar(year, 2);
break;
case 2:
printf( "七月八月九月\n");
printf( "-------------------- -------------------- --------------------\n");
mfDays = 31;
msOfWeek = zhouji(year, 8, 1);
msDays = 31;
mtOfWeek = zhouji(year, 9, 1);
mtDays = 30;
PrintOneQuarter(year, mfOfWeek, mfDays, msOfWeek, msDays, mtOfWeek, mtDays,hang);
msDays = 31;
mtOfWeek = zhouji(year, 6, 1);
mtDays = 30;
PrintOneQuarter(year, mfOfWeek, mfDays, msOfWeek, msDays, mtOfWeek, mtDays,hang);
break;
case 3:
mfOfWeek = zhouji(year, 7, 1);
#include<stdio.h>
#include <string.h>
void PrintCalendar(int year) ;
void PrintCommonCalendar(int year, int hang);
void PrintOneQuarter(int year, int mfOfWeek, int mfDays,
{
int mfDay = 1, msDay = 1, mtDay = 1;
int i, j,h;
if (hang == 1)
{
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
msDays = 29;
}
for (i = 0; i < 6; ++i)
+ 2, mfDay + 3, mfDay + 4, mfDay + 5, mfDay + 6);
mfDay += 7;
}
else
{ printf(" \n");
for (j = 0; j < 7; ++j)
{
if (mfDay <= mfDays)
printf("%-2d ", mfDay++);
int msOfWeek, msDays;
int mtOfWeek, mtDays;
switch (hang)
{
casBaidu Nhomakorabea 1:
mfOfWeek = zhouji(year, 1, 1);
mfDays = 31;
msOfWeek = zhouji(year, 2, 1);
msDays = 28;
mtOfWeek = zhouji(year, 3, 1);
{
if (i == 0)
{
if (mfOfWeek > 0)
for(h=0;h<mfOfWeek;h++)
printf(" ");
for (j = mfOfWeek; j < 7; ++j)
{
printf("%2d ", mfDay);
mfDay++;
}
printf(" ");
if (msOfWeek > 0)
mtDays = 31;
PrintOneQuarter(year, mfOfWeek, mfDays, msOfWeek, msDays, mtOfWeek, mtDays, hang);
break;
case 2:
mfOfWeek = zhouji(year, 4, 1);
mfDays = 30;
msOfWeek = zhouji(year, 5, 1);
printf( "日一二三四五六日一二三四五六日一二三四五六\n");
PrintCommonCalendar(year, 3);
break;
case 3:
printf( "十月十一月十二月\n");
printf( "-------------------- -------------------- --------------------\n");
printf(" ");
for (j = mtOfWeek; j < 7; ++j)
{
printf("%-2d ", mtDay);
mtDay++;
}
printf(" ");
continue;
}
if (i < 4)
{
printf(
"\n%-2d %-2d %-2d %-2d %-2d %-2d %-3d %-2d %-2d %-2d %-2d %-2d %-2d %-3d %-2d %-2d %-2d %-2d %-2d %-2d %-3d",
return i;
}
int totaldays(int year, int month, int day)
{
int days = 0;
switch (month)
{
case 1:days = day;break;
case 2:days = 31 + day;break;
case 3:days = 59 + day;break;
case 10:days = 273 + day;break;
case 11:days = 304 + day;break;
case 12:days = 334 + day;break;
default:break;
}
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)