Skip to content

Instantly share code, notes, and snippets.

@Sergaav
Created March 31, 2015 14:28
Show Gist options
  • Save Sergaav/82cbee26b5f5dfdaa46e to your computer and use it in GitHub Desktop.
Save Sergaav/82cbee26b5f5dfdaa46e to your computer and use it in GitHub Desktop.
dz4_1
package com.gmail.sergaav.dz4_1;
public class dz4_1 {
public static void main(String[] args) {
int[][] mas = { { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1 }, };
System.out.println("Заданный массив: \n ");
for (int i = 0; i < mas.length; i++) {
for (int j = 0; j < mas[i].length; j++) {
System.out.print(mas[i][j] + "");
}
System.out.println();
}
for (int i = 0; i < mas.length; i++) {
for (int j = i; j < mas.length; j++) {
int x = mas[i][j];
mas[i][j] = mas[j][i];
mas[j][i] = x;
}
}
System.out.println("Полученный массив: \n");
for (int i = 0; i < mas.length; i++) {
for (int j = 0; j < mas[i].length; j++) {
System.out.print(mas[i][j] + "");
}
System.out.println();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment