검색결과 리스트
글
달력 깔끔한듯
#include<stdio.h>
int m_day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
char *week[7]={"일","월","화","수","목","금","토"};
int main()
{
int year,month,day;
int total;
int Ly;
int start[13]; //각달의 요일번호
int all_day[13][45]={0,};
int num1,num2,num3; //각각출력할떄 넘버
int num=1; //저장할때 넘버
int s=1;//출력달번호
year=2012;
month=12;
//이번년 윤달확인
if((year%4==0) && ( (year%400==0) || year%100!=0))
m_day[2]=29;
else
m_day[2]=28;
//윤달계산
Ly=year-1;
total=Ly+(Ly/4)-(Ly/100)+(Ly/400)+1;
start[1]=total%7;
for(int i=1;i<12;i++)
{
total=total+m_day[i];
start[i+1]=total%7;
}
//배열에 저장
for(int m=1;m<13;++m)
{
printf("%d월\n",m);
printf("일월화수목금토\n");
num=1; //날짜 변수 초기화
for(int i=1;i<=42;++i)
{
if(i<=start[m]) //공백
printf(" ");
else //날짜 일
{
all_day[m][i]=num++;
printf("%2d",all_day[m][i]);
}
if(i%7==0 && i!=1) //줄갱신
{
printf("\n");
}
//마지막일까지 찍히면 브뤠이크
if(num>m_day[m])
break;
}
printf("\n");
}
printf("%d년의 1월1일은 %s요일이다\n",year,week[start[1]]);
for(int i=0;i<4;i++)
{
printf("%d월\t\t\t%d월\t\t\t%d월\n",s,s+1,s+2);
printf("일월화수목금토\t\t일월화수목금토\t\t일월화수목금토\n");
num1=num2=num3=1;
for(int x=1;x<7;++x)
{
for(int j=1;j<8;++j)
{
if(all_day[s][num1]==0)
printf(" ");
else
printf("%2d",all_day[s][num1]);
num1++;
}
printf("\t\t");
for(int j=1;j<8;++j)
{
if(all_day[s+1][num2]==0)
printf(" ");
else
printf("%2d",all_day[s+1][num2]);
num2++;
}
printf("\t\t");
for(int j=1;j<8;++j)
{
if(all_day[s+2][num3]==0)
printf(" ");
else
printf("%2d",all_day[s+2][num3]);
num3++;
}
printf("\n");
}
s=s+3;
}
}