SMALL
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { int year,dal,month; int months[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; int total_day=0,total_1,total_2; int i; while(1) { total_1 = 0; total_2 = 1; printf("년,월을 입력하세요(종료는 0) : "); scanf("%d",&year); if(year == 0) { break; } scanf("%d",&month); for(i = 0; i<year - 1; i++) // 알고리즘 1 { if((((i + 1) % 4) == 0 && (((i + 1) % 100) != 0)) || (((i + 1) % 400) == 0)) dal = 366; else { dal = 365; } total_1 += dal; } for(i = 0; i < month-1; i++) // 알고리즘 2 { if(((year % 4) == 0 && ((year % 100) != 0)) || ((year % 400) == 0)) months[1] = 29; else { months[1] = 28; } total_2 += months[i]; } total_day = total_1 + total_2; // 총일수 printf("\n"); printf(" %d년 %d월\n",year,month); printf(" ==============\n"); printf("------------------------------------\n"); printf(" SUN MON TUE WED THU FRI SAT\n"); printf("------------------------------------\n"); for(i = 1; i <= (((total_day % 7) % 7)); i++) // 공백 추가 printf(" "); for(i = 1; i <= months[month-1]; i++) { printf("%5d",i); if((i +(total_day % 7)) % 7 ==0) printf("\n"); } printf("\n"); printf("\n"); } return 0; } | cs |
LIST
'개인자료 > 프로그래밍' 카테고리의 다른 글
[C언어] 채점 프로그램 (0) | 2015.05.09 |
---|---|
[C언어] 소수(Prime Number) 출력 프로그램 (1) | 2015.05.09 |
[C언어] 1부터 10까지의 합 계산(재귀호출 사용) (2) | 2015.05.09 |
[C언어] 성적관리 프로그램 (0) | 2015.05.09 |
[150420 ~ 150507] 3주간의 전주 합숙 교육 후기 (1) | 2015.05.08 |
[C언어] 소수(Prime Number) 출력 프로그램 (0) | 2015.05.08 |
[C언어] 숫자 맞추기 게임 (3) | 2015.05.08 |
[C언어] 전기요금 계산 프로그램 (1) | 2015.05.08 |
[C언어] 장학금 계산 프로그램 (5) | 2015.05.08 |
[C언어] 계산기 프로그램 (0) | 2015.05.08 |