NgPPhung- Super Moderator
- Giới tính : Bài gửi : 73
Tổng Điểm : 144
Điểm Thưởng : 8
Sinh Nhật : 26/04/1990 Bị Dụ Dỗ : 11/09/2009
Tuổi : 34
by NgPPhung 11/9/2009, 21:23
- Code:
#include "stdio.h"
main()
{
int m,y,dow,i,j,top,y1,m1;
char c;
do{
m=1;
printf("nhap nam: ");
scanf("%d",&y);
y1=y-(14-m)/12;
m1=m+12*((14-m)/12)-2;
dow=(1+y1+y1/4-y1/100+y1/400+(31*m1)/12)%7;
do{
printf("\n\n ");
printf("thang %d",m);
printf(" \n");
dow%=7;
switch(m)
{
case 4: case 6: case 9: case 11 : top=30;break;
case 2: top=(y%4==0 && y%100!=0 || y%400==0)?29: 28;break;
default: top=31;
}
printf("+---+---+---+---+---+---+--+\n");
printf("%4s%4s%4s%4s%4s%4s%4s%4s\n","Sun","Mon","Tue","Wen","Thu","Fri","Sat");
j=1;
for(i=0;i<7;++i)
if(i<dow)
printf("%4c",' ');
else
printf("%4d",j++);
putchar('\n');
do{
for(i=0;i<7;++i)
if(j<=top)
printf("%4d",j++);
putchar('\n');
}while(j<=top);
dow+=top;
}while(++m<=12);
printf("co muon tiep tuc khong(y/n) ?");
scanf("%c%c",&c,&c);
}while(c=='y');
return 0;
}