这个闰年的伪代码有什么问题?
What's wrong with this pseudo code for leap year?
使用 if else end if 的正确伪代码应该是什么
input Year
if(Year % 4 == 0 and Year % 100 != 0) then
display "It is a leap year"
else if(Year % 400 == 0) then
display "It is a leap year"
else
display "It is not a leap year"
end-if
您的逻辑以相反的顺序列出。伪代码应该是:
1) 如果年份能被400整除,则是闰年
2) 如果年份不能被400整除,但是可以被100整除,则不是闰年
3) 如果年份不能被400整除,也不能被100整除,但是能被4整除,那么是闰年
4) 否则不是闰年。
使用 if else end if 的正确伪代码应该是什么
input Year
if(Year % 4 == 0 and Year % 100 != 0) then
display "It is a leap year"
else if(Year % 400 == 0) then
display "It is a leap year"
else
display "It is not a leap year"
end-if
您的逻辑以相反的顺序列出。伪代码应该是:
1) 如果年份能被400整除,则是闰年
2) 如果年份不能被400整除,但是可以被100整除,则不是闰年
3) 如果年份不能被400整除,也不能被100整除,但是能被4整除,那么是闰年
4) 否则不是闰年。