实现一个反转程序,要求:不能使用库函数。
such as: 输入:123 输出:321
输入:asdf 输出:fdsa
欢迎大家试试。不难,考基础。
import java.io.*;
import java.awt.event.*;
class Transfer
{
public static void main(String[] args) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print( "Please input: ");
String inputString = in.readLine();
char[] inputChar = inputString.toCharArray();
System.out.print( "The result:-----> ");
for(int i = inputChar.length-1;i > = 0;i--)
System.out.print(inputChar[i]);
System.out.println();
}
}