Guest User

Untitled

a guest
Dec 14th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. +public class Task6 {
  2. + public static void main(String[] args) {
  3. + int [][] array = new int [5][];
  4. + for (int i = 0; i < 5; i++){
  5. + array[i] = new int [i+1];
  6. + for (int j = 0; j <= i; j++){
  7. + array[i][j]=(int)(Math.random()*20);
  8. + }
  9. + }
  10. + directArray(array);
  11. + horizont(array);
  12. + vertical(array);
  13. + diagonal(array);
  14. + }
  15. +
  16. + public static void directArray(int [][] array){
  17. + System.out.println("Триугольный массив: ");
  18. + for (int[] array1 : array) {
  19. + for (int j = 0; j < array1.length; j++) {
  20. + System.out.print(array1[j] + " ");
  21. + }
  22. + System.out.println();
  23. + }
  24. + System.out.println();
  25. + }
  26. +
  27. + public static void horizont (int [][] array){
  28. + System.out.println("Горизонтальное отражение: ");
  29. + for (int i = array.length - 1; i >= 0; i--){
  30. + for (int j = 0; j < array[i].length; j++){
  31. + System.out.print(array[i][j] + " ");
  32. + }
  33. + System.out.println();
  34. + }
  35. + System.out.println();
  36. + }
  37. +
  38. + public static void vertical (int [][] array){
  39. + String space = "";
  40. +
  41. + System.out.println("Вертикальное отражение: ");
  42. + for (int[] array1 : array) {
  43. + for (int a = 0; a < 3 * (array.length - array1.length); a++) {
  44. + space += " ";
  45. + }
  46. + System.out.print(space);
  47. + space = "";
  48. + for (int j = array1.length - 1; j >= 0; j--) {
  49. + System.out.print(array1[j] + " ");
  50. + }
  51. + System.out.println();
  52. + }
  53. + System.out.println();
  54. + }
  55. +
  56. + public static void diagonal(int [][] array){
  57. + String space = "";
  58. + System.out.println("Горизонтальное и вертикальное отражение: ");
  59. + for (int i = array.length - 1; i >= 0; i--){
  60. + for (int a = 0; a < (array.length-array[i].length)*3; a++){
  61. + space += " ";
  62. + }
  63. + System.out.print(space);
  64. + space = "";
  65. + for (int j = array[i].length - 1; j >= 0; j--){
  66. + System.out.print(array[i][j] + " ");
  67. + }
  68. + System.out.println();
  69. + }
  70. +
  71. + }
  72. +
  73. +}
Add Comment
Please, Sign In to add comment