我想写一个程序,用户输入" asdfg"程序应该打印" gfdsa"我怎样才能做到这一点?我对此一无所知。
String s;
String rev;
Scanner sc = new Scanner (System.in);
System.out.println ("Enter 's' String : ");
s = sc.next();
System.out.println ("reverse of " + s + " equal to " + rev);
答案 0 :(得分:0)
试
System.out.println ("reverse of " + s + " equal to " + new StringBuilder(s).reverse().toString());
答案 1 :(得分:0)
试试这个,它会起作用
string input = "sample text";
char[] outputArray = input.ToCharArray();
Array.Reverse(outputArray);
Console.WriteLine(outputArray);