在面试问卷上看到这个。有什么想法吗?
Saw this on interview questionaire. Any thoughts?
--- 代码从这一行以下开始 ---
A:想一个程序::
B:James Requenez 的思考::
C: 银联一 "Hello World"::
D: CUP 2 IS "What year were you born?"::
E: CUP 3 IS "Enter first value"::
F: CUP 4 IS "Enter second value"::
G: CUP 5 是“二”
H: CUP 6 IS ::
我:::
J: 闻五::
K:闻 "one" 吐一个:>
L: 跳跃 Z::
M: SMELL "two" SPIT 二:>
N: SIP 苹果:>
O: 吐嚼现在切片苹果 SEW "years old":>
P: 跳跃 Y::
问:闻"three"吐三:>
R: SIP 香蕉:>
S:吐出四:>
T: SIP 胡萝卜:>
U: SPIT CHEW 香蕉 SEW 胡萝卜:>
V: 跳跃 Z::
W: SMELL "four" SPIT 四:>
X: SIP 代基里酒::
Y: 吐 "thank you"::
Z:随地吐痰"bye"::
::::
--- 此行上方的代码片段结束
你能解释一下这段代码的作用吗?如果有的话,输出是什么?
你能找出语法错误吗?
你能找出一个逻辑错误吗?
这是我的猜测:
the program prints "What year were you born?"
then reads the value in variable apple
then prints (current year - apple) "year old"
then prints "thank you"
then prints "bye"
and terminates
语法错误在 G 行(行尾缺少 ::)
逻辑错误是W行(写"Enter second value"而没有写"Enter first value")。
这些是命令:
思考 - 评论
CUP x IS y - 将 x 绑定到 y
SNIFF - 案例
气味 - 一个案例测试
JUMP - 跳跃
SIP x - 从输入流读取到变量 x
x 切片 y - (x - y)
咀嚼 x SEW y - x || y
--- 代码从这一行以下开始 ---
A:想一个程序::
B:James Requenez 的思考::
C: 银联一 "Hello World"::
D: CUP 2 IS "What year were you born?"::
E: CUP 3 IS "Enter first value"::
F: CUP 4 IS "Enter second value"::
G: CUP 5 是“二”
H: CUP 6 IS ::
我:::
J: 闻五::
K:闻 "one" 吐一个:>
L: 跳跃 Z::
M: SMELL "two" SPIT 二:>
N: SIP 苹果:>
O: 吐嚼现在切片苹果 SEW "years old":>
P: 跳跃 Y::
问:闻"three"吐三:>
R: SIP 香蕉:>
S:吐出四:>
T: SIP 胡萝卜:>
U: SPIT CHEW 香蕉 SEW 胡萝卜:>
V: 跳跃 Z::
W: SMELL "four" SPIT 四:>
X: SIP 代基里酒::
Y: 吐 "thank you"::
Z:随地吐痰"bye"::
::::
--- 此行上方的代码片段结束
你能解释一下这段代码的作用吗?如果有的话,输出是什么?
你能找出语法错误吗?
你能找出一个逻辑错误吗?
这是我的猜测:
the program prints "What year were you born?"
then reads the value in variable apple
then prints (current year - apple) "year old"
then prints "thank you"
then prints "bye"
and terminates
语法错误在 G 行(行尾缺少 ::)
逻辑错误是W行(写"Enter second value"而没有写"Enter first value")。
这些是命令:
思考 - 评论
CUP x IS y - 将 x 绑定到 y
SNIFF - 案例
气味 - 一个案例测试
JUMP - 跳跃
SIP x - 从输入流读取到变量 x
x 切片 y - (x - y)
咀嚼 x SEW y - x || y