Note: StringBuilder.reverse () after inverting the original string and will write the address of the original string, numeric characters can be converted to use the cast
How to say both to understand it, feel this question poisonous!
An understanding that, if five words, it is "ABCDEDCBABCDE" taken a continuous cycle length above five strings. Another is to be understood that, taken from the "ZYX ... CBABC ... XYZ" character string length of five
/ ** problems described using letters may be composed of some beautiful graphics, an example is given below: ABCDEFG BABCDEF CBABCDE DCBABCD EDCBABC This is a pattern row 5 7, find the pattern of this rule, and outputs a n row m graphic column. Input format input line, comprising two integers n and m, respectively represent the number of columns you want output line pattern. Output format output n lines, each m characters, for your pattern. Input Sample 57 Sample Output ABCDEFG BABCDEF CBABCDE DCBABCD EDCBABC data size and Conventions 1 <= n, m <= 26. * / Package jiChuLianXi; Import java.util.Scanner; public class LetterFig { // public static void main (String [] args) { // // TODO Auto-generated method stub // Scanner in = new Scanner(System.in); // int n = in.nextInt(), m = in.nextInt(); // String constStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // StringBuilder str = new StringBuilder(constStr.substring(0, m)); // StringBuilder s = new StringBuilder(str.toString()); // s.append(str.reverse().substring(1)); // s.append(str.reverse().substring(1)); //// System.out.println(s.length()-m); // int sumLines = s.length()-m; // for(int j=0; j<n; j++){ //// System.out.println(":" + (sumLines-j%sumLines) + " " + (sumLines-j%sumLines+m)); // System.out.println(s.substring(sumLines-j%sumLines, sumLines-j%sumLines+m)); // } // in.close(); // } public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n = sc.nextInt();//接收行数 int m = sc.nextInt();//接收列数 //将A-Z放入a[]中 int[] a = new int[26]; char s = 'A'; for(int i=0;i<26;i++) { a[i] = s+i; } //循环 for(int i=0;i<n;i++) { for(int j=i;j>=i-m+1&&j>-1;j--) { System.out.print((char)a[j]); } for(int k=1;k<=m-i-1;k++) { System.out.print((char)a[k]);//数字转化为字符+ } System.out.println(); } }} /** import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n = sc.nextInt();//接收行数 int m = sc.nextInt();//接收列数 //将A-Z放入a[]中 int[] a = new int[26]; char s = 'A'; for(int i=0;i<26;i++) { a[i] = s+i; } //循环 for(int i=0;i<n;i++) { for(int j=i;j>=i-m+1&&j>-1;j--) { System.out.print((char)a[j]); } for (int. 1 = K; K <= mi The-. 1; K ++) { System.out.print ((char) a [k ]); // number into character } System.out.println (); } } } * /