-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ejercicio26.java
69 lines (61 loc) · 2.07 KB
/
Ejercicio26.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
*Ejercicio # 26
Realice un programa que compruebe si una matriz dada es anti simétrica. Se dice
que una matriz A es anti simétrica cuando ésta es igual a su propia traspuesta, pero
cambiada de signo. Es decir, A es anti simétrica si A = -AT. La matriz traspuesta de
una matriz A se denota por AT y se obtiene cambiando sus filas por columnas (o
viceversa).
*/
package egg_ejercicios;
import java.util.Scanner;
/**
*
* @author WALTER GOMEZ
*/
public class Ejercicio26 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner leer = new Scanner(System.in).useDelimiter("\n");
//DecimalFormat df = new DecimalFormat("###.##");
Integer tam = 0;
boolean teste = false;
System.out.println("ingrese el tamaño de la matriz");
tam = leer.nextInt();
Integer mat[][] = new Integer[tam][tam];
Integer m[][] = new Integer[tam][tam];
System.out.println("ingrese los elementos de la matriz");
for (int i = 0; i < tam; i++) {
for (int j = 0; j < tam; j++) {
System.out.println("columna" + (i + 1) + " fila" + (j + 1));
mat[i][j] = leer.nextInt();
m[i][j] = mat[i][j];
}
}
for (int i = 0; i < tam; i++) {
for (int j = 0; j < tam; j++) {
mat[j][i] = mat[i][j];
}
}
for (int i = 0; i < tam; i++) {
for (int j = 0; j < tam; j++) {
m[i][j] = -m[i][j];
}
}
for (int i = 0; i < tam; i++) {
for (int j = 0; j < tam; j++) {
if ((mat[j][i]) == (m[i][j])) {
teste = true;
} else {
teste = false;
}
}
}
if (teste == true) {
System.out.println("la matriz es antisimétrica");
} else {
System.out.println("la matriz no es antisimétrica");
}
}
}