Set indent to tabs and applied format to project

This commit is contained in:
Carlos Galindo 2019-03-26 20:29:29 +01:00
parent 782a4361c2
commit 0e5667582b
Signed by untrusted user who does not match committer: kauron
GPG key ID: 83E68706DEE119A3
21 changed files with 586 additions and 634 deletions

View file

@ -0,0 +1,14 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="JAVA">
<indentOptions>
<option name="USE_TAB_CHARACTER" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="USE_TAB_CHARACTER" value="true" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>

View file

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View file

@ -25,14 +25,7 @@ package grafos;
****************************************************************************** ******************************************************************************
*/ */
import java.io.BufferedReader; import java.io.*;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.Properties; import java.util.Properties;
/** /**
@ -61,18 +54,10 @@ import java.util.Properties;
* *
* </dl> * </dl>
* *
* @version v0.5.1, 2013/03/18 (March) -- Patch of Juan Hoyos (Mac support)
* @version v0.5, 2012/04/24 (April) -- Patch of Abdur Rahman (OS detection + start subgraph +
* read config file)
* @version v0.4, 2011/02/05 (February) -- Patch of Keheliya Gallaba is added. Now you
* can specify the type of the output file: gif, dot, fig, pdf, ps, svg, png, etc.
* @version v0.3, 2010/11/29 (November) -- Windows support + ability to read the graph from a text file
* @version v0.2, 2010/07/22 (July) -- bug fix
* @version v0.1, 2003/12/04 (December) -- first release
* @author Laszlo Szathmary (<a href="jabba.laci@gmail.com">jabba.laci@gmail.com</a>) * @author Laszlo Szathmary (<a href="jabba.laci@gmail.com">jabba.laci@gmail.com</a>)
* @version v0.1, 2003/12/04 (December) -- first release
*/ */
public class GraphViz public class GraphViz {
{
/** /**
* Detects the client's operating system. * Detects the client's operating system.
*/ */
@ -83,10 +68,13 @@ public class GraphViz
*/ */
private final static String cfgProp = "./src/main/res/config.properties"; private final static String cfgProp = "./src/main/res/config.properties";
private final static Properties configFile = new Properties() { private final static Properties configFile = new Properties() {
private final static long serialVersionUID = 1L; { private final static long serialVersionUID = 1L;
{
try { try {
load(new FileInputStream(cfgProp)); load(new FileInputStream(cfgProp));
} catch (Exception ignored) {} } catch (Exception ignored) {
}
} }
}; };
@ -103,7 +91,7 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
/** /**
* The image size in dpi. 96 dpi is normal size. Higher values are 10% higher each. * The image size in dpi. 96 dpi is normal size. Higher values are 10% higher each.
* Lower values 10% lower each. * Lower values 10% lower each.
* * <p>
* dpi patch by Peter Mueller * dpi patch by Peter Mueller
*/ */
private int[] dpiSizes = {46, 51, 57, 63, 70, 78, 86, 96, 106, 116, 128, 141, 155, 170, 187, 206, 226, 249}; private int[] dpiSizes = {46, 51, 57, 63, 70, 78, 86, 96, 106, 116, 128, 141, 155, 170, 187, 206, 226, 249};
@ -149,6 +137,7 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
/** /**
* Returns the graph's source description in dot language. * Returns the graph's source description in dot language.
*
* @return Source of the graph in dot language. * @return Source of the graph in dot language.
*/ */
public String getDotSource() { public String getDotSource() {
@ -182,65 +171,68 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
/** /**
* Returns the graph as an image in binary format. * Returns the graph as an image in binary format.
*
* @param dot_source Source of the graph to be drawn. * @param dot_source Source of the graph to be drawn.
* @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png. * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png.
* @return A byte array containing the image of the graph. * @return A byte array containing the image of the graph.
*/ */
public byte[] getGraph(String dot_source, String type) public byte[] getGraph(String dot_source, String type) {
{
File dot; File dot;
byte[] img_stream; byte[] img_stream;
try { try {
dot = writeDotSourceToFile(dot_source); dot = writeDotSourceToFile(dot_source);
if (dot != null) if (dot != null) {
{
img_stream = get_img_stream(dot, type); img_stream = get_img_stream(dot, type);
if (!dot.delete()) if (!dot.delete())
System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!"); System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!");
return img_stream; return img_stream;
} }
return null; return null;
} catch (java.io.IOException ioe) { return null; } } catch (java.io.IOException ioe) {
return null;
}
} }
/** /**
* Writes the graph's image in a file. * Writes the graph's image in a file.
*
* @param img A byte array containing the image of the graph. * @param img A byte array containing the image of the graph.
* @param file Name of the file to where we want to write. * @param file Name of the file to where we want to write.
* @return Success: 1, Failure: -1 * @return Success: 1, Failure: -1
*/ */
public int writeGraphToFile(byte[] img, String file) public int writeGraphToFile(byte[] img, String file) {
{
File to = new File(file); File to = new File(file);
return writeGraphToFile(img, to); return writeGraphToFile(img, to);
} }
/** /**
* Writes the graph's image in a file. * Writes the graph's image in a file.
*
* @param img A byte array containing the image of the graph. * @param img A byte array containing the image of the graph.
* @param to A File object to where we want to write. * @param to A File object to where we want to write.
* @return Success: 1, Failure: -1 * @return Success: 1, Failure: -1
*/ */
public int writeGraphToFile(byte[] img, File to) public int writeGraphToFile(byte[] img, File to) {
{
try { try {
FileOutputStream fos = new FileOutputStream(to); FileOutputStream fos = new FileOutputStream(to);
fos.write(img); fos.write(img);
fos.close(); fos.close();
} catch (java.io.IOException ioe) { return -1; } } catch (java.io.IOException ioe) {
return -1;
}
return 1; return 1;
} }
/** /**
* It will call the external dot program, and return the image in * It will call the external dot program, and return the image in
* binary format. * binary format.
*
* @param dot Source of the graph (in dot language). * @param dot Source of the graph (in dot language).
* @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png. * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png.
* @return The image of the graph in .gif format. * @return The image of the graph in .gif format.
*/ */
private byte[] get_img_stream(File dot, String type) private byte[] get_img_stream(File dot, String type) {
{
File img; File img;
byte[] img_stream = null; byte[] img_stream = null;
@ -262,13 +254,11 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
if (!img.delete()) if (!img.delete())
System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!"); System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!");
} } catch (java.io.IOException ioe) {
catch (java.io.IOException ioe) {
System.err.println("Error: in I/O processing of tempfile in dir " + GraphViz.TEMP_DIR + "\n"); System.err.println("Error: in I/O processing of tempfile in dir " + GraphViz.TEMP_DIR + "\n");
System.err.println(" or in calling external command"); System.err.println(" or in calling external command");
ioe.printStackTrace(); ioe.printStackTrace();
} } catch (java.lang.InterruptedException ie) {
catch (java.lang.InterruptedException ie) {
System.err.println("Error: the execution of the external program was interrupted"); System.err.println("Error: the execution of the external program was interrupted");
ie.printStackTrace(); ie.printStackTrace();
} }
@ -279,11 +269,11 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
/** /**
* Writes the source of the graph in a file, and returns the written file * Writes the source of the graph in a file, and returns the written file
* as a File object. * as a File object.
*
* @param str Source of the graph (in dot language). * @param str Source of the graph (in dot language).
* @return The file (as a File object) that contains the source of the graph. * @return The file (as a File object) that contains the source of the graph.
*/ */
private File writeDotSourceToFile(String str) throws java.io.IOException private File writeDotSourceToFile(String str) throws java.io.IOException {
{
File temp; File temp;
try { try {
temp = File.createTempFile("dorrr", ".dot", new File(GraphViz.TEMP_DIR)); temp = File.createTempFile("dorrr", ".dot", new File(GraphViz.TEMP_DIR));
@ -294,8 +284,7 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
br.flush(); br.flush();
br.close(); br.close();
fout.close(); fout.close();
} } catch (Exception e) {
catch (Exception e) {
System.err.println("Error: I/O error while writing the dot source to temp file!"); System.err.println("Error: I/O error while writing the dot source to temp file!");
return null; return null;
} }
@ -304,6 +293,7 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
/** /**
* Returns a string that is used to start a graph. * Returns a string that is used to start a graph.
*
* @return A string to open a graph. * @return A string to open a graph.
*/ */
public String start_graph() { public String start_graph() {
@ -312,6 +302,7 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
/** /**
* Returns a string that is used to end a graph. * Returns a string that is used to end a graph.
*
* @return A string to close a graph. * @return A string to close a graph.
*/ */
public String end_graph() { public String end_graph() {
@ -321,6 +312,7 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
/** /**
* Takes the cluster or subgraph id as input parameter and returns a string * Takes the cluster or subgraph id as input parameter and returns a string
* that is used to start a subgraph. * that is used to start a subgraph.
*
* @return A string to open a subgraph. * @return A string to open a subgraph.
*/ */
public String start_subgraph(int clusterid) { public String start_subgraph(int clusterid) {
@ -329,6 +321,7 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
/** /**
* Returns a string that is used to end a graph. * Returns a string that is used to end a graph.
*
* @return A string to close a graph. * @return A string to close a graph.
*/ */
public String end_subgraph() { public String end_subgraph() {
@ -341,12 +334,10 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
* @param input Input text file containing the DOT graph * @param input Input text file containing the DOT graph
* source. * source.
*/ */
public void readSource(String input) public void readSource(String input) {
{
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
try try {
{
FileInputStream fis = new FileInputStream(input); FileInputStream fis = new FileInputStream(input);
DataInputStream dis = new DataInputStream(fis); DataInputStream dis = new DataInputStream(fis);
BufferedReader br = new BufferedReader(new InputStreamReader(dis)); BufferedReader br = new BufferedReader(new InputStreamReader(dis));
@ -355,8 +346,7 @@ private static String DOT = configFile.getProperty("dotFor" + osName);
sb.append(line); sb.append(line);
} }
dis.close(); dis.close();
} } catch (Exception e) {
catch (Exception e) {
System.err.println("Error: " + e.getMessage()); System.err.println("Error: " + e.getMessage());
} }

View file

@ -1,15 +1,15 @@
package grafos; package grafos;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import com.github.javaparser.JavaParser; import com.github.javaparser.JavaParser;
import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Node; import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.comments.Comment; import com.github.javaparser.ast.comments.Comment;
import com.github.javaparser.ast.visitor.VoidVisitor; import com.github.javaparser.ast.visitor.VoidVisitor;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class Transformador { public class Transformador {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
@ -50,8 +50,7 @@ public class Transformador {
} }
// Imprime el grafo en la pantalla // Imprime el grafo en la pantalla
private static String imprimirGrafo(List<String> arcos) private static String imprimirGrafo(List<String> arcos) {
{
StringBuilder dotInfo = new StringBuilder(); StringBuilder dotInfo = new StringBuilder();
for (String arco : arcos) { for (String arco : arcos) {
dotInfo.append(arco); dotInfo.append(arco);
@ -66,8 +65,7 @@ public class Transformador {
// Elimina todos los comentarios de un nodo y sus hijos // Elimina todos los comentarios de un nodo y sus hijos
private static void quitarComentarios(Node node) { private static void quitarComentarios(Node node) {
node.removeComment(); node.removeComment();
for (Comment comment : node.getOrphanComments()) for (Comment comment : node.getOrphanComments()) {
{
node.removeOrphanComment(comment); node.removeOrphanComment(comment);
} }
// Do something with the node // Do something with the node

View file

@ -1,7 +1,5 @@
package grafos; package grafos;
import java.util.List;
import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.stmt.BlockStmt; import com.github.javaparser.ast.stmt.BlockStmt;
@ -9,9 +7,10 @@ import com.github.javaparser.ast.stmt.ExpressionStmt;
import com.github.javaparser.ast.stmt.Statement; import com.github.javaparser.ast.stmt.Statement;
import com.github.javaparser.ast.visitor.VoidVisitorAdapter; import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
import java.util.List;
public class Visitador extends VoidVisitorAdapter<List<String>>
{ public class Visitador extends VoidVisitorAdapter<List<String>> {
//********************************************************/ //********************************************************/
//********************** Atributos ***********************/ //********************** Atributos ***********************/
//********************************************************/ //********************************************************/
@ -28,8 +27,7 @@ public class Visitador extends VoidVisitorAdapter<List<String>>
// Visitador de métodos // Visitador de métodos
// Este visitador añade el nodo final al CFG // Este visitador añade el nodo final al CFG
@Override @Override
public void visit(MethodDeclaration methodDeclaration, List<String>collector) public void visit(MethodDeclaration methodDeclaration, List<String> collector) {
{
// Visitamos el método // Visitamos el método
super.visit(methodDeclaration, collector); super.visit(methodDeclaration, collector);
@ -40,8 +38,7 @@ public class Visitador extends VoidVisitorAdapter<List<String>>
// Visitador de expresiones // Visitador de expresiones
// Cada expresión encontrada genera un nodo en el CFG // Cada expresión encontrada genera un nodo en el CFG
@Override @Override
public void visit(ExpressionStmt es, List<String>collector) public void visit(ExpressionStmt es, List<String> collector) {
{
// Creamos el nodo actual // Creamos el nodo actual
nodoActual = crearNodo(es); nodoActual = crearNodo(es);
@ -54,8 +51,7 @@ public class Visitador extends VoidVisitorAdapter<List<String>>
} }
// Añade un arco desde el último nodo hasta el nodo actual (se le pasa como parametro) // Añade un arco desde el último nodo hasta el nodo actual (se le pasa como parametro)
private void añadirArcoSecuencialCFG(List<String>collector) private void añadirArcoSecuencialCFG(List<String> collector) {
{
System.out.println("NODO: " + nodoActual); System.out.println("NODO: " + nodoActual);
String arco = nodoAnterior + "->" + nodoActual + ";"; String arco = nodoAnterior + "->" + nodoActual + ";";
@ -63,29 +59,25 @@ public class Visitador extends VoidVisitorAdapter<List<String>>
} }
// Crear arcos // Crear arcos
private void crearArcos(List<String>collector) private void crearArcos(List<String> collector) {
{
añadirArcoSecuencialCFG(collector); añadirArcoSecuencialCFG(collector);
} }
// Crear nodo // Crear nodo
// Añade un arco desde el nodo actual hasta el último control // Añade un arco desde el nodo actual hasta el último control
private String crearNodo(Object objeto) private String crearNodo(Object objeto) {
{
return "\"(" + contador++ + ") " + quitarComillas(objeto.toString()) + "\""; return "\"(" + contador++ + ") " + quitarComillas(objeto.toString()) + "\"";
} }
// Sustituye " por \" en un string: Sirve para eliminar comillas. // Sustituye " por \" en un string: Sirve para eliminar comillas.
private static String quitarComillas(String texto) private static String quitarComillas(String texto) {
{
return texto.replace("\"", "\\\""); return texto.replace("\"", "\\\"");
} }
// Dada una sentencia, // Dada una sentencia,
// Si es una <EFBFBD>nica instrucci<EFBFBD>n, devuelve un bloque equivalente // Si es una <EFBFBD>nica instrucci<EFBFBD>n, devuelve un bloque equivalente
// Si es un bloque, lo devuelve // Si es un bloque, lo devuelve
private BlockStmt convertirEnBloque(Statement statement) private BlockStmt convertirEnBloque(Statement statement) {
{
if (statement instanceof BlockStmt) if (statement instanceof BlockStmt)
return (BlockStmt) statement; return (BlockStmt) statement;

View file

@ -2,12 +2,10 @@ package ejemplos;
public class Bucles_1 { public class Bucles_1 {
public static void main(String[] args) public static void main(String[] args) {
{
// BUCLE WHILE (sin anidamiento) // BUCLE WHILE (sin anidamiento)
int x = 1; int x = 1;
while (x<=10) while (x <= 10) {
{
System.out.print(x); System.out.print(x);
x++; x++;
} }

View file

@ -2,18 +2,15 @@ package ejemplos;
public class Bucles_2 { public class Bucles_2 {
public static void main(String[] args) public static void main(String[] args) {
{
// BUCLE WHILE anidado a otro WHILE // BUCLE WHILE anidado a otro WHILE
System.out.println("Empieza bucle WHILE anidado a otro WHILE:"); System.out.println("Empieza bucle WHILE anidado a otro WHILE:");
int x = 1; int x = 1;
char y = 'a'; char y = 'a';
while (x<=10) while (x <= 10) {
{
System.out.print(" " + x); System.out.print(" " + x);
y = 'a'; y = 'a';
while (y<='c') while (y <= 'c') {
{
System.out.print(" " + y); System.out.print(" " + y);
y++; y++;
} }

View file

@ -7,8 +7,7 @@ public class Bucles_3 {
// BUCLE FOR (sin anidamiento) // BUCLE FOR (sin anidamiento)
System.out.println("Empieza bucle FOR:"); System.out.println("Empieza bucle FOR:");
for (x=1;x<=10;x++) for (x = 1; x <= 10; x++) {
{
System.out.print(" " + x); System.out.print(" " + x);
} }
System.out.println(); System.out.println();
@ -16,8 +15,7 @@ public class Bucles_3 {
// BUCLE WHILE (sin anidamiento) // BUCLE WHILE (sin anidamiento)
System.out.println("Empieza bucle WHILE:"); System.out.println("Empieza bucle WHILE:");
x = 1; x = 1;
while (x<=10) while (x <= 10) {
{
System.out.print(" " + x); System.out.print(" " + x);
x++; x++;
} }

View file

@ -2,13 +2,11 @@ package ejemplos;
public class Bucles_4 { public class Bucles_4 {
public static void main(String[] args) public static void main(String[] args) {
{
int x = 1; int x = 1;
//Bucle 1: Contador //Bucle 1: Contador
while (x<10) while (x < 10) {
{
System.out.println(x); System.out.println(x);
x++; x++;
} }
@ -16,8 +14,7 @@ public class Bucles_4 {
//Bucle 2: Sumatorio //Bucle 2: Sumatorio
int suma = 0; int suma = 0;
int y = 1; int y = 1;
while (y<10) while (y < 10) {
{
suma += y; suma += y;
y++; y++;
} }
@ -27,8 +24,7 @@ public class Bucles_4 {
int sumatorio = 0; int sumatorio = 0;
int min = 10; int min = 10;
int max = 100; int max = 100;
for (int num = min; num <= max; num++) for (int num = min; num <= max; num++) {
{
sumatorio += num; sumatorio += num;
} }
System.out.println(sumatorio); System.out.println(sumatorio);

View file

@ -8,11 +8,9 @@ public class Bucles_5 {
// BUCLE FOR anidado a otro FOR // BUCLE FOR anidado a otro FOR
System.out.println("Empieza bucle FOR anidado a otro FOR:"); System.out.println("Empieza bucle FOR anidado a otro FOR:");
for (x=1;x<=10;x++) for (x = 1; x <= 10; x++) {
{
System.out.print(" " + x); System.out.print(" " + x);
for (y='a';y<='c';y++) for (y = 'a'; y <= 'c'; y++) {
{
System.out.print(" " + y); System.out.print(" " + y);
} }
} }
@ -21,12 +19,10 @@ public class Bucles_5 {
// BUCLE WHILE anidado a otro WHILE // BUCLE WHILE anidado a otro WHILE
System.out.println("Empieza bucle WHILE anidado a otro WHILE:"); System.out.println("Empieza bucle WHILE anidado a otro WHILE:");
x = 1; x = 1;
while (x<=10) while (x <= 10) {
{
System.out.print(" " + x); System.out.print(" " + x);
y = 'a'; y = 'a';
while (y<='c') while (y <= 'c') {
{
System.out.print(" " + y); System.out.print(" " + y);
y++; y++;
} }
@ -39,8 +35,7 @@ public class Bucles_5 {
x = 1; x = 1;
do { do {
System.out.print(" " + x); System.out.print(" " + x);
for (y='a';y<='c';y++) for (y = 'a'; y <= 'c'; y++) {
{
System.out.print(" " + y); System.out.print(" " + y);
} }
x++; x++;

View file

@ -2,23 +2,19 @@ package ejemplos;
public class Bucles_6 { public class Bucles_6 {
public static void main(String[] args) public static void main(String[] args) {
{
// BUCLE WHILE (sin anidamiento) // BUCLE WHILE (sin anidamiento)
System.out.println("Empieza bucle WHILE:"); System.out.println("Empieza bucle WHILE:");
int x = 1; int x = 1;
while (x<=10) while (x <= 10) {
{
System.out.print(" " + x); System.out.print(" " + x);
x++; x++;
while (x<=10) while (x <= 10) {
{
System.out.print(" " + x); System.out.print(" " + x);
x++; x++;
} }
} }
while (x<=10) while (x <= 10) {
{
System.out.print(" " + x); System.out.print(" " + x);
x++; x++;
} }

View file

@ -2,8 +2,7 @@ package ejemplos;
public class Test_1 { public class Test_1 {
public static void main(String[] args) public static void main(String[] args) {
{
System.out.println("HOLA mundo"); System.out.println("HOLA mundo");
int x = 1; int x = 1;
x = 2; x = 2;

View file

@ -2,8 +2,7 @@ package ejemplos;
public class Test_2 { public class Test_2 {
public static void main(String[] args) public static void main(String[] args) {
{
int x = 1; int x = 1;
x++; x++;
++x; ++x;

View file

@ -2,8 +2,7 @@ package ejemplos;
public class Test_3 { public class Test_3 {
public static void main(String[] args) public static void main(String[] args) {
{
int x = 1; int x = 1;
if (x == 1) if (x == 1)

View file

@ -2,15 +2,12 @@ package ejemplos;
public class Test_4 { public class Test_4 {
public static void main(String[] args) public static void main(String[] args) {
{
int x = 1; int x = 1;
if (x==1) if (x == 1) {
{
x = 2; x = 2;
if (x>=1) if (x >= 1) {
{
x = 3; x = 3;
x = 4; x = 4;
} }

View file

@ -2,15 +2,12 @@ package ejemplos;
public class Test_5 { public class Test_5 {
public static void main(String[] args) public static void main(String[] args) {
{
int x = 1; int x = 1;
if (x==1) if (x == 1) {
{
x = 2; x = 2;
if (x>=1) if (x >= 1) {
{
x = 3; x = 3;
x = 4; x = 4;
} }

View file

@ -2,17 +2,13 @@ package ejemplos;
public class Test_6 { public class Test_6 {
public static void main(String[] args) public static void main(String[] args) {
{
int x = 1; int x = 1;
if (x==1) if (x == 1) {
{
x = 2; x = 2;
x = 3; x = 3;
} } else {
else
{
x = 4; x = 4;
x = 5; x = 5;
} }

View file

@ -3,21 +3,16 @@ package ejemplos;
public class Test_7 { public class Test_7 {
public static void main(String[] args) public static void main(String[] args) {
{
int x = 1; int x = 1;
if (x==1) if (x == 1) {
{
x = 2; x = 2;
} } else x = 3;
else x=3;
x = 4; x = 4;
if (x==2) if (x == 2) {
{
x = 5; x = 5;
} } else if (x == 3) x = 6;
else if (x==3) x=6;
x = 7; x = 7;
} }
} }

View file

@ -2,18 +2,15 @@ package ejemplos;
public class Test_8 { public class Test_8 {
public static void main(String[] args) public static void main(String[] args) {
{
int x = 1; int x = 1;
if (x==1) if (x == 1) {
{
x = 2; x = 2;
} }
x = 5; x = 5;
x = 6; x = 6;
if (x==2) if (x == 2) {
{
x = 7; x = 7;
} }
if (x == 3) x = 8; if (x == 3) x = 8;

View file

@ -3,27 +3,21 @@ package ejemplos;
public class Test_9 { public class Test_9 {
public static void main(String[] args) public static void main(String[] args) {
{
// ANIDAMIENTO de IF y WHILE // ANIDAMIENTO de IF y WHILE
// ANIDAMIENTO de IF y WHILE 2 // ANIDAMIENTO de IF y WHILE 2
int x = 0; int x = 0;
if (x>1) if (x > 1) {
{
x = 1; x = 1;
while (x>2) while (x > 2) {
{
x = 2; x = 2;
while (x>3) while (x > 3) {
{
x = 3; x = 3;
if (x>4) if (x > 4) {
{
x = 4; x = 4;
if (x>5) if (x > 5) {
{
x = 5; x = 5;
} }
x--; x--;