上一次小测试的参考答案如下:
没有做出来,不怪你,因为我们才刚刚学了一点类的皮毛。但是今天学完了,再练习,以后类似题目就简单了。
今天测试题:
Question 6
Level 2
Question:
Write aprogram that calculates and prints the value according to the given formula:
Q = Squareroot of [(2* C * D)/H]
Following are the fixed values of C and H:
C is 50. H is 30.
D is the variable whose values should be input to your program in a comma-separated sequence.
写一个程序,根据给定的公式计算并打印值,公式 Q = [2CD/H] 这个式子的平方根,C = 50, H = 30, D是input函数从键盘输入的值。假如我们只是输入3个值,分别是100, 150, 180. 结果应该是 18, 22, 24.
要求:如果结果是带小数点的浮点数,应该取整。
已经是第二个level水平了,稍微难一点,多尝试尝试吧。
今天找了一个系统但相对简单的英文材料,来系统学习类的定义等有关内容,我在原文翻译的基础上,适当加上了自己的注解和说明,总体应该是相当权威的。