Advertisement
Guest User

Untitled

a guest
Dec 26th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public static final char alphabet[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  2.  
  3.  
  4. public static char defLettre(int j) {
  5. char result = alphabet[j];
  6.  
  7. return result;
  8.  
  9. }
  10.  
  11. public static void runThis(int n) {
  12.  
  13. for (int l = 1; l <= 2 * n - 1; l++) {
  14. System.out.println("\n");
  15. for (int c = 1; c <= 2 * n - 1; c++) {
  16. boolean match = false;
  17. for (int j = 1; j < 2 * n; j++) {
  18. if ((l == 1) || (l == 2 * n - j) || (c == 1) || (c == 2 * n - j)) {
  19. if (j == 1) {
  20. System.out.print('a');
  21. } else {
  22. System.out.print(defLettre(j - 1));
  23. }
  24. match = true;
  25. break;
  26.  
  27. }
  28.  
  29. }
  30.  
  31. }
  32.  
  33. }
  34.  
  35. }
  36. }
  37.  
  38.  
  39. J'obtiens ça :
  40.  
  41. aaaaaaa
  42.  
  43. afedcba
  44.  
  45. aeedcba
  46.  
  47. adddcba
  48.  
  49. accccba
  50.  
  51. abbbbba
  52.  
  53. aaaaaaa
  54.  
  55. Je veux obtenir ça :
  56.  
  57. aaaaaaa
  58. abbbbba
  59. abcccba
  60. abcdcba
  61. abcccba
  62. abbbbba
  63. aaaaaaa
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement