2个回答
2013-07-24
展开全部
public class a_516 {
public static void main(String[ ] args) {
int n0 = 1, n1 = 1, n2;
System.out.print(n0 + "\t" + n1 + "\t"); int num=0; for(int i = 0; i < 18; i++) { num++;if(num%5=o){ System.out.println(); }
n2 = n1 + n0;
System.out.print(n2 + "\t");
n0 = n1;
n1 = n2;
}
System.out.println( );
}
}手写的不知道对不对你试试
public static void main(String[ ] args) {
int n0 = 1, n1 = 1, n2;
System.out.print(n0 + "\t" + n1 + "\t"); int num=0; for(int i = 0; i < 18; i++) { num++;if(num%5=o){ System.out.println(); }
n2 = n1 + n0;
System.out.print(n2 + "\t");
n0 = n1;
n1 = n2;
}
System.out.println( );
}
}手写的不知道对不对你试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-24
展开全部
package src;public class Fibonacci {
public Fibonacci(int i) {
int x = 0, c;
int a = 1;
int b = 1;
System.out.print(a + " " + b);
while (x <= i) {
c = a + b;
System.out.print(" " + c);
a = b;
b = c;
x += 1;
}
} public static void main(String[] args) {
new Fibonacci(5);//参数你可以自己设置
}
} 如果:1 1 2 3 5 8 13 21
public Fibonacci(int i) {
int x = 0, c;
int a = 1;
int b = 1;
System.out.print(a + " " + b);
while (x <= i) {
c = a + b;
System.out.print(" " + c);
a = b;
b = c;
x += 1;
}
} public static void main(String[] args) {
new Fibonacci(5);//参数你可以自己设置
}
} 如果:1 1 2 3 5 8 13 21
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询