這是我去面試時的考題,
當時笨笨的,一直想不出來
(在此感謝建安,崇德及86的幫忙)
VB語法:
Dim x, y, z, n As Integer
x = 0
y = 0
z = 0
For n = 10 To 0 Step -1
Console.WriteLine(y)
z = x + y
If z = 0 Then z += 1
x = y
y = z
Next
Java:
int x = 0,y = 0,z = 0;
int size = 10;
while((size–)>= 0){
System.out.println ;
z = x+y;
if(z == 0)++z;
x = y;
y = z;
}