수정해야 되는 곳 좀 부탁드립니다.
해찬솔
2023.04.01
#include stdio.h
int main(void)
{
int y1=2000;
int y2=2012;
int y3=2015;
printf(%d\n, ycalc(y1));
printf(%d\n, ycalc(y2));
printf(%d\n, ycalc(y3));
return 0;
}
int ycalc(int n)
{
int result;
if(n%4==0)
{
result = 1;
if((n%4==0)&& (n%100==0) && (n%400)==0)
result = 1;
}
else if
result = 0;
return result;
}
윤년구하는 소스인데
4로 나누어 떨어지는 년도는 윤년이다.
4로 나누어 떨어지지만 100으로도 나누어 떨어지는 년도는 윤년이 아니다.
4와 100으로 나누어 떨어지면서 400으로도 나누어 떨어지면 윤년이다.
어디를 수정해야 하는건가요 .. ??