1将【【112334444将汉字打印222出来】】中的汉字打印出来 package src; public class Dayin { public static void main(String[] args) { String s="112334444将汉字打印222出来"; for(int i=0;i<s.length();i++) { int n=(int)s.charAt(i); if(n>=19968&&n<=171941) { System.out.print(s.charAt(i)); } } } } 2 600个苹果装10个篮子的问题 package src; import java.util.Scanner; /** * * @author jinchun * */ public class Apple2 { /** * @param args */ public static void main(String[] args) { int apple = 0; int[] box = new int[10]; int apples = 600; for (int i = 0; i < box.length - 1; i++) { box[i] = apple; apple = apple * 2; } box[9] = apples - apple; int math = 0; boolean lab = false; boolean lastbox= false; while (lab == false) { try { System.out.println("请输入0-600之间的数字 "); Scanner input = new Scanner(System.in); math = input.nextInt(); if(math>600) { lab = false; } else { lab = true; } } catch (RuntimeException e) { lab = false; } } if(math>511) { math=math-89; lastbox=true; } String bin=Integer.toBinaryString(math); char[] bina=bin.toCharArray(); for(int i=0;i<bina.length;i++) { if("1".equals(bina[i]+"")) { System.out.print(bina.length-i+"号箱子 "); } } if(lastbox==true) { System.out.print("10号箱子 "); } } }