因为只要对字符串实施反序输出而没有更多的要求,所以是可以使用现成库和方法的简单题。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextLine()) {
String s = in.nextLine();
System.out.println(new StringBuffer(s).reverse());
}
}
}
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_DEPRECATE
int main() {
std::string sample;
while(std::cin >> sample){
std::reverse(sample.begin(),sample.end());
std::cout << sample << std::endl;
}
}