/*********************************************************************************/
/* Made By K.N (eu8198@hanmail.net) */
/*Algorythm; input month tab of year 2000, and plus 1 if the ycounter is not 윤년*/
/* and plus 2 if the ycounter is 윤년. */
/*********************************************************************************/
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
// Array // 배열 공간
int month_days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // 요일 수
int month_tap_2000[] = {0 ,6 ,2 ,3 ,6 ,1 ,4 ,6 ,2 ,5 ,0 ,3 ,5}; // 2000년의 빈공간 수
// Function // 함수 공간
void namemonth(); // 달의 이름출력
void monthtab(); // 그 달의 공간계산
//void print(); // 출력하는 함수
// integer // 정수변수 공간
int y, m, c; // year,month,counter의 약자
int plusc; // 그 달의 공간만큼 c에 플러스
char a;
void main(void)
{
cout << "Calender Program. Made by K.N\nIf you found some bugs, send e-mail to eu8198@sayclub.com"<<endl;
while(1){
y = 0; m = 0; c = 0;
cout << " Input year : ";
cin >> y;
cout << " Input month : ";
cin >> m;
if((y%4)==0) // 윤년 계산
{
if((y%100)==0)
{
if((y%400)==0)
month_days[2]=29;
}
else month_days[2] = 29;
}
system("cls"); // 입력부분 삭제
if(y<0)
cout << " BC "<<-y << " year ";
else
cout <<" " << y << " year ";
namemonth(); // 1 -> January .. 이런식으로 바꿔주는 함수
cout << "Sun Mon Tue Wed Thu Fri Sat"<<endl;
monthtab();
c = c+plusc;
for(int i=1;i<=month_days[m];i++)
{
if(i<10)cout << " "; // 자릿수 맞추기
cout <<i << " "; // 일정공간 띄우기
c++;
if(c%7==0)cout << "\n"; // 7로 나눠서 줄맞추기
}
cout << "\n";
cout << "Do you want to continue?[Y/N] : ";
cin >> a;
if(a == 'n' || a == 'N'){
system("cls");
cout << "Thank you for using it.^-^"<<endl;
exit(1);
}
else system("cls");
}
}
void namemonth()
{
switch(m)
{
case 1:cout << "January"<<endl; break;
case 2:cout << "February"<<endl; break;
case 3:cout << "March"<<endl; break;
case 4:cout << "April"<<endl; break;
case 5:cout << "May"<<endl; break;
case 6:cout << "June"<<endl; break;
case 7:cout << "July"<<endl; break;
case 8:cout << "August"<<endl; break;
case 9:cout << "September"<<endl; break;
case 10:cout << "October"<<endl; break;
case 11:cout << "November"<<endl; break;
case 12:cout << "December"<<endl; break;
default: cout << "error! Try again!!"; exit(1);
}
}
void monthtab()
{
int iy;
iy = 2000;
plusc = month_tap_2000[m];
if(y>2000)
{
while(iy != y){
iy++;
if((iy%4)==0)
{
if((iy%100)==0)
{
if((iy%400)==0)
plusc+=2;
else
plusc+=1;
}
else
plusc+=2;
}
else
plusc+=1;
}
}
else if(y == 2000){;}
else if(y<2000)
{
while(iy != y){
iy--;
if((iy%4)==0)
{
if((iy%100)==0)
{
if((iy%400)==0)
plusc-=2;
else
plusc-=1;
}
else
plusc-=2;
}
else
plusc-=1;
}
}
if(plusc>=7 || plusc<=-7) plusc%=7;
if(plusc<0)
{
plusc += 7;
}
for(int i = 0;i < plusc; i++)
{
cout << " ";
}
}
/* Made By K.N (eu8198@hanmail.net) */
/*Algorythm; input month tab of year 2000, and plus 1 if the ycounter is not 윤년*/
/* and plus 2 if the ycounter is 윤년. */
/*********************************************************************************/
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
// Array // 배열 공간
int month_days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // 요일 수
int month_tap_2000[] = {0 ,6 ,2 ,3 ,6 ,1 ,4 ,6 ,2 ,5 ,0 ,3 ,5}; // 2000년의 빈공간 수
// Function // 함수 공간
void namemonth(); // 달의 이름출력
void monthtab(); // 그 달의 공간계산
//void print(); // 출력하는 함수
// integer // 정수변수 공간
int y, m, c; // year,month,counter의 약자
int plusc; // 그 달의 공간만큼 c에 플러스
char a;
void main(void)
{
cout << "Calender Program. Made by K.N\nIf you found some bugs, send e-mail to eu8198@sayclub.com"<<endl;
while(1){
y = 0; m = 0; c = 0;
cout << " Input year : ";
cin >> y;
cout << " Input month : ";
cin >> m;
if((y%4)==0) // 윤년 계산
{
if((y%100)==0)
{
if((y%400)==0)
month_days[2]=29;
}
else month_days[2] = 29;
}
system("cls"); // 입력부분 삭제
if(y<0)
cout << " BC "<<-y << " year ";
else
cout <<" " << y << " year ";
namemonth(); // 1 -> January .. 이런식으로 바꿔주는 함수
cout << "Sun Mon Tue Wed Thu Fri Sat"<<endl;
monthtab();
c = c+plusc;
for(int i=1;i<=month_days[m];i++)
{
if(i<10)cout << " "; // 자릿수 맞추기
cout <<i << " "; // 일정공간 띄우기
c++;
if(c%7==0)cout << "\n"; // 7로 나눠서 줄맞추기
}
cout << "\n";
cout << "Do you want to continue?[Y/N] : ";
cin >> a;
if(a == 'n' || a == 'N'){
system("cls");
cout << "Thank you for using it.^-^"<<endl;
exit(1);
}
else system("cls");
}
}
void namemonth()
{
switch(m)
{
case 1:cout << "January"<<endl; break;
case 2:cout << "February"<<endl; break;
case 3:cout << "March"<<endl; break;
case 4:cout << "April"<<endl; break;
case 5:cout << "May"<<endl; break;
case 6:cout << "June"<<endl; break;
case 7:cout << "July"<<endl; break;
case 8:cout << "August"<<endl; break;
case 9:cout << "September"<<endl; break;
case 10:cout << "October"<<endl; break;
case 11:cout << "November"<<endl; break;
case 12:cout << "December"<<endl; break;
default: cout << "error! Try again!!"; exit(1);
}
}
void monthtab()
{
int iy;
iy = 2000;
plusc = month_tap_2000[m];
if(y>2000)
{
while(iy != y){
iy++;
if((iy%4)==0)
{
if((iy%100)==0)
{
if((iy%400)==0)
plusc+=2;
else
plusc+=1;
}
else
plusc+=2;
}
else
plusc+=1;
}
}
else if(y == 2000){;}
else if(y<2000)
{
while(iy != y){
iy--;
if((iy%4)==0)
{
if((iy%100)==0)
{
if((iy%400)==0)
plusc-=2;
else
plusc-=1;
}
else
plusc-=2;
}
else
plusc-=1;
}
}
if(plusc>=7 || plusc<=-7) plusc%=7;
if(plusc<0)
{
plusc += 7;
}
for(int i = 0;i < plusc; i++)
{
cout << " ";
}
}
댓글 달기 WYSIWYG 사용