问题描述
s01串初始为"0"
按以下方式变换
0变1,1变01
样例输入
3
样例输出
101
import java.util.Scanner;
public class S01串 {
/**
* @param args
*/
public static String f(int num){ //返回字符串
if(num==1){
return "1";
}
if (num==0) {
return "0";
}
return f(num-2)+f(num-1);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
System.out.println(f(num));
}
}
3
101