다 풀었다!! ㅠ 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 (비회원)
    • 글자 크기

댓글 달기 WYSIWYG 사용

글쓴이 비밀번호
twone
2003.11.19 조회 195
twone
2019.01.21 조회 131
2
의문의 K군
2003.11.03 조회 125
은지
2012.06.05 조회 107
twone
2020.07.06 조회 104
twone
2012.06.06 조회 104
twone
2018.12.01 조회 97
twone
2011.08.26 조회 69
H.S.J..♥
2011.03.14 조회 66
이지원
2011.02.27 조회 66
twone
2011.09.04 조회 65
노진호
2012.05.31 조회 63
twone
2012.06.04 조회 63
Skywalker
2011.09.03 조회 63
twone
2011.03.23 조회 63
2011.01.16 조회 63
twone
2011.01.17 조회 63
Skywalker
2011.08.22 조회 61
twone
2011.03.23 조회 61
H.S.J..♥
2011.01.10 조회 61
이전 1 2 3 4 5 6 7 8 9 10... 86다음
첨부 (0)