import java.util.Scanner; public class Fei { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("请输入要输出几个数:"); int num =sc.nextInt(); int a=1; int b=1; int c=0; for (int i=1;i<=num;i++) if (i==1||i==2){ System.out.print(1 + "\t"); }else{ c=a+b; a=b; b=c; System.out.print(c + "\t"); } } } 十进制转二进制
package Add; import java.util.Scanner; public class Er { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("请输入一个整数:"); int a=sc.nextInt(); String b=""; while(a!=0){ int i=a%2; b=i+b; a=a/2; } System.out.println(b); } }