把这个答案整理出来了
Scanner sc = new Scanner(System.in);
StringBuffer sb = new StringBuffer();
for(int i=0;i<5;i++){
System.out.println("请输入数字");
int aa=sc.nextInt();
sb.append(aa);
}
String ss=sb.reverse().toString();
System.out.println(ss);
BufferedWriter bw = new BufferedWriter(new FileWriter("a.txt"));
bw.write(ss);
bw.flush();
bw.close(); |