반응형

예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
 
 
int main()
{
    int days[13= {0,31,28,31,30,31,30,31,31,30,31,30,31};
    int year,month;
 
    while(1){
        printf("YEAR :");
        scanf("%d"&year);
        printf("MONTH :");
        scanf("%d"&month);
 
        if(month == 0){
            break;
        }
        else if(month <= 0 || month > 12){
            printf("404 error");
        }
        else{
            if(year % 400 == 0) days[2= 29;
            else if(year % 4 == 0 && year % 100 != 0) days[2= 29;
            else days[2= 28;
            printf("지금 입력하신 달의 끝은 %d일 입니다.",days[month]);
        }
        printf("\n");
    }
    return 0;
}
 

반응형

+ Recent posts