Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Solution {
- public static void main(String[] args) throws IOException{
- final int len = 5;
- String a = "DOOOO";
- char[][] gen = new char[len][len];
- for (int i = 0; i < len; i++) {
- reset(gen);
- copyRow(a, gen, i);
- print(gen);
- }
- for (int i =0; i < len; i++) {
- reset(gen);
- copyColumn(a, gen, i);
- print(gen);
- }
- }
- private static void print(char [][] gen) {
- for (int i = 0; i < gen.length; i++) {
- System.out.println(new String(gen[i]));
- }
- System.out.println("------------------");
- }
- private static void reset(char[][] gen) {
- for (int i = 0; i < gen.length; i++) {
- for (int j = 0; j < gen.length; j++) {
- gen[i][j] = 'T';
- }
- }
- }
- private static void copyRow(String x, char[][] gen, int row) {
- for (int i = 0; i < x.length(); i++) {
- gen[row][i] = x.charAt(i);
- }
- }
- private static void copyColumn(String x, char[][] gen, int column) {
- for (int i = 0; i < x.length(); i++) {
- gen[i][column] = x.charAt(x.length() - i - 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement