#include <stdio.h>
int main(void) {
   char name[][7] = {"일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"};
   int month_day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
   int i, year, month, day;
   int total = 0;
   printf("생 년 월 일 을 입력하세요. Ex) 2011 3 3\n");
   scanf("%d%d%d", &year, &month, &day);
   total += (year - 1) * 365;
   total += (year - 1) / 4;
   total -= (year - 1) / 100;
   total += (year - 1) / 400;
   for(i = 0;i < (month - 1);i++)
      total += month_day[i];
   if(month >= 3 && (year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0)
      total += 1;
   total += day;
   total = total % 7;
   printf("당신의 생일은 %s 입니다!\n", name[total]);
   return 0;
}

'Programming > C' 카테고리의 다른 글

1 ~ 1000000 까지 소수 구하는 프로그램  (0) 2011.03.13

+ Recent posts