/*
打印日历
要求格式如下:
January February
Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat
1 2 3 1 2 3 4 5 6 7
4 5 6 7 8 9 10 8 9 10 11 12 13 14
11 12 13 14 15 16 17 15 16 17 18 19 20 21
18 19 20 21 22 23 24 22 23 24 25 26 27 28
25 26 27 28 29 30 31 29
*/
#include<stdio.h>
main()
{
int i,j;
printf("\tJanuary\t\t\t\t\tFebruary\n");
printf("Sun Mon Tue Wed Thu Fri Sat ");
printf("Sun Mon Tue Wed Thu Fri Sat\n");
printf(" ");
for(j=1;j<=3;j++){
printf("%2d ",j);
}
printf(" ");
for(j=1;j<=7;j++){
printf("%2d ",j);
}
putchar('\n');
for(i=1;i<=4;i++){
for(j=7*i-3;j<=7*i+3;j++){
printf("%2d ",j);
}
printf(" ");
if(i!=4){
for(j=7*i+1;j<=7*i+7;j++){
printf("%2d ",j);
}
}
else
for(j=7*i+1;j<=7*i+1;j++){
printf("%2d ",j);
}
putchar('\n');
}
}
感觉这个程序太繁琐,能提供一个更好的吗?谢谢 ~~
[此贴子已经被作者于2007-11-18 10:35:48编辑过]