#include <stdio.h>
int getTotalDates(int, int, int);
int maxDayMonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
int main(void)
{
int year, month, date, total;
printf("총 일수를 알고 싶은 날짜의 년, 월, 일을 다음과 같이 입력하세요. >>\n");
scanf("%d %d %d", &year, &month, &date);
if( (year<1) || (month>12 && month<1) || (date<1 && date>maxDayMonth[month]))
{
printf("잘못 입력하셨습니다. 다시 입력하세요.\n");
scanf("%d %d %d", &year, &month, &date);
}
total = getTotalDates(year,month,date);
printf("%4d년 %3d월 %3d일의 총 일수는 %7d입니다.\n", year, month, date, total);
return 0;
}
int getTotalDates(int year, int month, int date)
{
int i,j,total=0;
for(i=0;i<(year-1);i++)
{
if(year % 4 == 0) && (year % 100 !=0) || (year % 400 == 0))
{
maxDayMonth[1]=29;
}
else
{
maxDayMonth[1]=28;
}
for(j=0;j<12;j++)
{
total+=maxDayMonth[i];
}
}
for(i=0;i<(month-1);i++)
{
total+=maxDayMonth[i];
}
total+=date;
return total;
}
어째 들여쓰기가 하나도 안되네..
이상한데서 꼬투리 잡혀요.. 뒤에 함수구현 부분에서 자꾸 ;가 빠졌느니 syntax error 막 열몇개씩 띄우고...
왜이러지;