我需要使用“ case”,但我不知道如何使用。我必须编写一个读取一个月的数字的程序,并且该程序给出该月有多少天。但是当我输入任何数字时,请说对象xxx不适用。有人可以帮助我吗?
(clear)
(display "Ingrese Un numero de Mes: ")
(define mes (read))
(if (and (integer? mes)(>= mes 1)(<= mes 12))
(case (mes)
((4 6 9 11)(display 30))
((1 3 5 7 8 10 12) (display 31))
(else (display 28 ))
)
)
你括号太多了。应该是(case mes ...)
,不是(case (mes) ...)
。它不像C风格switch
。:-)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句