具体代码如下:
public class While1 {
public static void main(String[] args) {
int a = 0;
int b = 1;
int c = 1;
StringBuilder result = new StringBuilder();
while(c < 89) {
c = a + b;
if(c == 1) {
//如果c是第三位的值,把a,b的加到result中
result.append(a);
result.append(" ");
result.append(b);
result.append(" ");
}
result.append(c);
result.append(" ");
//b的值付给a
a = b;
//c的值付给b
b = c;
}
System.out.println(result.toString());
}
}