日期:2014-05-20 浏览次数:20895 次
import java.io.*; import java.util.*; class hh { public static void main(String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuffer sb = new StringBuffer(); String line = null; while((line=br.readLine())!=null){ if(line.equals("#")) break; sb.append(line); sb.reverse(); System.out.println(sb); } // System.out.println("Hello World!"); } }
------解决方案--------------------
import java.util.Scanner; public class Test { public static void main(String[] args) { int num = 0; Scanner input = new Scanner(System.in); StringBuffer sb = new StringBuffer(); while(!input.hasNext("#")){ sb.append(input.next()); } System.out.println(sb.length()); System.out.println(sb.reverse()); } }
------解决方案--------------------
import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); StringBuilder sd = new StringBuilder(); String s = ""; while(!(s = in.next()).equals("#")) { sd.append(s); } System.out.println(sd.toString().length()); System.out.println(sd.reverse()); } }