Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public class Solution {
  2.  
  3.  
  4. public static void main(String[] args) throws IOException{
  5. final int len = 5;
  6. String a = "DOOOO";
  7. char[][] gen = new char[len][len];
  8.  
  9. for (int i = 0; i < len; i++) {
  10. reset(gen);
  11. copyRow(a, gen, i);
  12. print(gen);
  13. }
  14.  
  15. for (int i =0; i < len; i++) {
  16. reset(gen);
  17. copyColumn(a, gen, i);
  18. print(gen);
  19. }
  20. }
  21.  
  22. private static void print(char [][] gen) {
  23. for (int i = 0; i < gen.length; i++) {
  24. System.out.println(new String(gen[i]));
  25. }
  26. System.out.println("------------------");
  27. }
  28.  
  29. private static void reset(char[][] gen) {
  30. for (int i = 0; i < gen.length; i++) {
  31. for (int j = 0; j < gen.length; j++) {
  32. gen[i][j] = 'T';
  33. }
  34. }
  35. }
  36.  
  37. private static void copyRow(String x, char[][] gen, int row) {
  38. for (int i = 0; i < x.length(); i++) {
  39. gen[row][i] = x.charAt(i);
  40. }
  41. }
  42.  
  43. private static void copyColumn(String x, char[][] gen, int column) {
  44. for (int i = 0; i < x.length(); i++) {
  45. gen[i][column] = x.charAt(x.length() - i - 1);
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement