다 풀었다!! ㅠ oㅠ

Twone2004.02.14 19:37조회 수 8댓글 0

    • 글자 크기
/*********************************************************************************/
/*                        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 << "    ";
        }
}
Twone (비회원)
    • 글자 크기
(by 조재윤) (by Twone)

댓글 달기 WYSIWYG 사용

글쓴이 비밀번호
twone
2003.12.18 조회 19
twone
2003.12.19 조회 32
twone
2003.12.22 조회 15
twone
2004.02.01 조회 3
뷁뷰뫲
2003.12.23 조회 15
박병선
2003.12.28 조회 17
SP
2004.01.29 조회 10
twone
2004.02.01 조회 17
김용덕
2004.01.30 조회 13
twone
2004.02.01 조회 18
김용덕
2004.01.30 조회 15
twone
2004.02.06 조회 10
twone
2004.02.06 조회 15
twone
2004.02.06 조회 14
twone
2004.02.11 조회 11
Twone
2004.02.13 조회 4
조재윤
2004.02.12 조회 7
/*********************************************************************************/ /* 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 윤년. */ /***************************************************...
Twone
2004.02.14 조회 8
Twone
2004.02.13 조회 10
Twone
2004.02.27 조회 1
이전 1 ... 3 4 5 6 7 8 9 10 11 12... 86다음
첨부 (0)