반응형
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #include <stdio.h> #include <math.h> #define TODAY_YEAR 2016 #define TODAY_MONTH 6 #define TODAY_DAY 9 #define MYPI 3.141592 // 1997.3.4 ---> 2016.5.26 // year: 1998 - 2015: 365, 366 // month. 1997.4,5,...,12 + 2016.1,2,3,4 (30,31, 28, 29) // day: 1997 (31-4), 2016 (26) int isLunarYear(int _year); // returns how many days in month of year int howManyDaysInMonthOfYear(int _year, int _month) { int monthData[] = {0,31, 28, 31, 30, 31, 30, 31,31,30,31,30,31 }; if (isLunarYear(_year) == 1 && _month == 2) { return 29; } else { return monthData[_month]; } } // returns 1 if _year is lunar year // 0 otherwise. int isLunarYear(int _year) { if (((_year % 4) == 0 && (_year % 100) != 0) || (_year % 400) == 0) { return 1; } return 0; } // returns how many days elapsed since _year._month._day until today. // int howManyDays(int _year, int _month, int _day) { int days = 0; // year-based counting for (int i = _year+1; i < TODAY_YEAR; i++) { if (isLunarYear(i) == 1) { days = days + 366; } else { days = days + 365; } } // month_based counting for (int i = _month + 1; i <= 12; i++) { days = days + howManyDaysInMonthOfYear(_year, i); } for (int i = 1; i <= (TODAY_MONTH-1); i++) { days = days + howManyDaysInMonthOfYear(TODAY_YEAR, i); } // day-based counting days = days + TODAY_DAY; days = days + (howManyDaysInMonthOfYear(_year, _month) - _day); return days; } int main(void) { int _y = 1997; int _m = 8; int _d = 11; //scanf("%d %d %d", &_y, &_m, &_d); int days = howManyDays(_y, _m, _d); printf("생년월일 %d년 %d월 %d일 출생한, \n", _y, _m, _d); printf("당신은 %d년 %d월 %d일 기준으로 총 %d일을 살았음.\n", TODAY_YEAR, TODAY_MONTH, TODAY_DAY, days); double physical = sin((2.0*MYPI*days) / 23.0); double emotional = sin((2.0*MYPI*days) / 28.0); double intelligence = sin((2.0*MYPI*days) / 33.0); printf("신체지수: %.2f\n", physical); printf("감정지수: %.2f\n", emotional); printf("지성지수: %.2f\n", intelligence); return 0; } |
반응형
LIST