第一行有一个整数。
随后组数据。
每组的第一行有一个整数。
每组的第二行有一个字符串,仅包含小写英文字符。
保证。
输出行,每行一个字符串,代表倒置后的字符串
。
3 5 abcde 8 redocwon 9 tfarcenim
edcba nowcoder minecraft
int t = in.nextInt(); for (int i = 0; i < t; i++) { int n = in.nextInt(); String s = in.next(); System.out.println(new StringBuffer(s).reverse().toString()); }
#include <stdio.h> int main() { long int num = 0; /* 当前组有多少个字符 */ long int t = 0; /* 一共多少组 */ char a[100000]; /* 有多少组 */ scanf("%ld", &t); /* 循环打印每一组 */ while(t) { scanf("%ld", &num); /* 当前组有多少个字符 */ getchar(); for(long int i = 0; i < num; i++) { scanf("%c", &a[i]); } for(long int j = num - 1; j >= 0; j--) { printf("%c", a[j]); } printf("\n"); t--; } return 0; }
a = input() for i in range(int(a)*2): b = input() if i % 2 == 1: print(b[::-1])
//LINQ using System.Linq; public class Program { public static void Main() { int t = int.Parse(System.Console.ReadLine ()); for (int i = 0; i < t; i++) { System.Console.ReadLine ();//跳过长度 string line = System.Console.ReadLine (); System.Console.WriteLine(new string(line.Reverse().ToArray())); } } }
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = 0; if(in.hasNextInt()){ t = in.nextInt(); } while(0<t--){ if(in.hasNextInt()){ int n = in.nextInt(); } if(in.hasNext()){ StringBuilder sb = new StringBuilder(in.next()); System.out.println(sb.reverse()); } } in.close(); } }
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int A = in.nextInt(); while(A > 0){ A--; int B = in.nextInt(); in.nextLine();//去掉回车 String s = in.nextLine(); char[] c = s.toCharArray(); for(int i = s.length() - 1; i >= 0;i--){ System.out.print(c[i]); } System.out.println(""); } } }
#include <iostream> #include<string> #include<algorithm> using namespace std; int main() { long t,n; cin>>t; string s; char c; while(t--) { cin>>n; while(n--) { cin>>c; s.push_back(c); } reverse(s.begin(),s.end()); cout<<s<<endl; s.erase(s.begin(), s.end()); } } // 64 位输出请用 printf("%lld")