VFP程序设计:判断它是不是闰年。闰年的条件是:能被4整除但不能被100整除,或能被400整除。

给定一个年份(从键盘输入),判断它是不是闰年。闰年的条件是:能被4整除但不能被100整除,或能被400整除。

clear
set talk off
input "请输入4位数年份" to year
if year%4=0 and year%100=0 or mod(year,400)=0
?year,"是闰年"
else
?year,"不是闰年"
endif
set talk on
cancel
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-06-25
在 “是否闰年”按钮的Click事件编写如下代码:
x=year(thisform.text1.value)
if (x%4=0 and x%100#0) or x%400=0
thisform.text2.value="是闰年"
else
thisform.text2.value="不是闰年"
endif
thisform.refresh
相似回答