Title: Alphabet graphic
Problem description
Using letters to make up some beautiful graphics, here's an example:
ABCDEFG
Babcdef
Cbabcde
Dcbabcd
Edcbabc
This is a 5 row 7 column of graphics, please find out the pattern of this graph, and output a n row m column of graphics.
Input format
Enter a line that contains two integers n and m, representing the number of rows in the graph you want to output.
Output format
Output n rows, each M-character, for your graphics.
Sample input
5 7
Sample output
ABCDEFG
Babcdef
Cbabcde
Dcbabcd
Edcbabc
Data size and convention
1 <= N, M <= 26.
Analysis: Up to 26 English letters, each letter set is a subset of these 26 letters, so create an internal class to be responsible for generating the letter set, and then only need to remove the last character each time, the first one to add a character to form the next line of character sequence.
Source:
public class Test007 {public static void main (string[) args) {Scanner sc = new Scanner (system.in);
int row = Sc.nextint ();
int col = Sc.nextint ();
Sc.close ();
ABC abc = new ABC (COL);
StringBuffer sb = new StringBuffer (Abc.getcontent ());
System.out.println (Abc.getcontent ());
for (int i=1; i<row; i++) {//delete last character Sb.deletecharat (Sb.length ()-1);
char ch = sb.charat (0);
Inserts a character sb.insert (0, Abc.getprefix (CH)) at the front;
System.out.println (SB); }//Create an inner class that is responsible for generating the content string and getting the first character of a character is how much private static class abc{private static final String original = "ABCDE
FGHIJKLMNOPQRSTUVWXYZ ";
Private String content;
Public ABC (int len) {this.content = original.substring (0, Len);
Public String getcontent () {return content;
Public char getprefix (char ch) {int index = CONTENT.INDEXOF (CH);
index++;
if (index = = Content.length ()) {index = 0;
Return Content.charat (index); }
}
}