Set indent to tabs and applied format to project
This commit is contained in:
parent
782a4361c2
commit
0e5667582b
21 changed files with 586 additions and 634 deletions
|
@ -2,15 +2,13 @@ package ejemplos;
|
|||
|
||||
public class Bucles_1 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
// BUCLE WHILE (sin anidamiento)
|
||||
int x=1;
|
||||
while (x<=10)
|
||||
{
|
||||
int x = 1;
|
||||
while (x <= 10) {
|
||||
System.out.print(x);
|
||||
x++;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,19 +2,16 @@ package ejemplos;
|
|||
|
||||
public class Bucles_2 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
// BUCLE WHILE anidado a otro WHILE
|
||||
System.out.println("Empieza bucle WHILE anidado a otro WHILE:");
|
||||
int x=1;
|
||||
char y='a';
|
||||
while (x<=10)
|
||||
{
|
||||
System.out.print(" "+x);
|
||||
y='a';
|
||||
while (y<='c')
|
||||
{
|
||||
System.out.print(" "+y);
|
||||
System.out.println("Empieza bucle WHILE anidado a otro WHILE:");
|
||||
int x = 1;
|
||||
char y = 'a';
|
||||
while (x <= 10) {
|
||||
System.out.print(" " + x);
|
||||
y = 'a';
|
||||
while (y <= 'c') {
|
||||
System.out.print(" " + y);
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
|
|
|
@ -4,34 +4,32 @@ public class Bucles_3 {
|
|||
|
||||
public static void main(String[] args) {
|
||||
int x;
|
||||
|
||||
|
||||
// BUCLE FOR (sin anidamiento)
|
||||
System.out.println("Empieza bucle FOR:");
|
||||
for (x=1;x<=10;x++)
|
||||
{
|
||||
System.out.print(" "+x);
|
||||
System.out.println("Empieza bucle FOR:");
|
||||
for (x = 1; x <= 10; x++) {
|
||||
System.out.print(" " + x);
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
// BUCLE WHILE (sin anidamiento)
|
||||
System.out.println("Empieza bucle WHILE:");
|
||||
x=1;
|
||||
while (x<=10)
|
||||
{
|
||||
System.out.print(" "+x);
|
||||
System.out.println("Empieza bucle WHILE:");
|
||||
x = 1;
|
||||
while (x <= 10) {
|
||||
System.out.print(" " + x);
|
||||
x++;
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
// BUCLE DO WHILE (sin anidamiento)
|
||||
System.out.println("Empieza bucle DO WHILE:");
|
||||
x=1;
|
||||
do{
|
||||
System.out.print(" "+x);
|
||||
System.out.println("Empieza bucle DO WHILE:");
|
||||
x = 1;
|
||||
do {
|
||||
System.out.print(" " + x);
|
||||
x++;
|
||||
}
|
||||
while (x<=10);
|
||||
while (x <= 10);
|
||||
System.out.println();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,22 +2,19 @@ package ejemplos;
|
|||
|
||||
public class Bucles_4 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int x=1;
|
||||
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
|
||||
//Bucle 1: Contador
|
||||
while (x<10)
|
||||
{
|
||||
while (x < 10) {
|
||||
System.out.println(x);
|
||||
x++;
|
||||
}
|
||||
|
||||
//Bucle 2: Sumatorio
|
||||
int suma=0;
|
||||
int y=1;
|
||||
while (y<10)
|
||||
{
|
||||
int suma = 0;
|
||||
int y = 1;
|
||||
while (y < 10) {
|
||||
suma += y;
|
||||
y++;
|
||||
}
|
||||
|
@ -27,8 +24,7 @@ public class Bucles_4 {
|
|||
int sumatorio = 0;
|
||||
int min = 10;
|
||||
int max = 100;
|
||||
for (int num = min; num <= max; num++)
|
||||
{
|
||||
for (int num = min; num <= max; num++) {
|
||||
sumatorio += num;
|
||||
}
|
||||
System.out.println(sumatorio);
|
||||
|
|
|
@ -5,29 +5,25 @@ public class Bucles_5 {
|
|||
public static void main(String[] args) {
|
||||
int x = 0;
|
||||
char y = '0';
|
||||
|
||||
|
||||
// BUCLE FOR anidado a otro FOR
|
||||
System.out.println("Empieza bucle FOR anidado a otro FOR:");
|
||||
for (x=1;x<=10;x++)
|
||||
{
|
||||
System.out.print(" "+x);
|
||||
for (y='a';y<='c';y++)
|
||||
{
|
||||
System.out.print(" "+y);
|
||||
System.out.println("Empieza bucle FOR anidado a otro FOR:");
|
||||
for (x = 1; x <= 10; x++) {
|
||||
System.out.print(" " + x);
|
||||
for (y = 'a'; y <= 'c'; y++) {
|
||||
System.out.print(" " + y);
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
// BUCLE WHILE anidado a otro WHILE
|
||||
System.out.println("Empieza bucle WHILE anidado a otro WHILE:");
|
||||
x=1;
|
||||
while (x<=10)
|
||||
{
|
||||
System.out.print(" "+x);
|
||||
y='a';
|
||||
while (y<='c')
|
||||
{
|
||||
System.out.print(" "+y);
|
||||
System.out.println("Empieza bucle WHILE anidado a otro WHILE:");
|
||||
x = 1;
|
||||
while (x <= 10) {
|
||||
System.out.print(" " + x);
|
||||
y = 'a';
|
||||
while (y <= 'c') {
|
||||
System.out.print(" " + y);
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
|
@ -35,18 +31,17 @@ public class Bucles_5 {
|
|||
System.out.println();
|
||||
|
||||
// BUCLE FOR anidado a bucle DO WHILE
|
||||
System.out.println("Empieza bucle FOR anidado a bucle DO WHILE:");
|
||||
x=1;
|
||||
do{
|
||||
System.out.print(" "+x);
|
||||
for (y='a';y<='c';y++)
|
||||
{
|
||||
System.out.print(" "+y);
|
||||
System.out.println("Empieza bucle FOR anidado a bucle DO WHILE:");
|
||||
x = 1;
|
||||
do {
|
||||
System.out.print(" " + x);
|
||||
for (y = 'a'; y <= 'c'; y++) {
|
||||
System.out.print(" " + y);
|
||||
}
|
||||
x++;
|
||||
}
|
||||
while (x<=10);
|
||||
while (x <= 10);
|
||||
System.out.println();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,26 +2,22 @@ package ejemplos;
|
|||
|
||||
public class Bucles_6 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
// BUCLE WHILE (sin anidamiento)
|
||||
System.out.println("Empieza bucle WHILE:");
|
||||
int x=1;
|
||||
while (x<=10)
|
||||
{
|
||||
System.out.print(" "+x);
|
||||
System.out.println("Empieza bucle WHILE:");
|
||||
int x = 1;
|
||||
while (x <= 10) {
|
||||
System.out.print(" " + x);
|
||||
x++;
|
||||
while (x<=10)
|
||||
{
|
||||
System.out.print(" "+x);
|
||||
while (x <= 10) {
|
||||
System.out.print(" " + x);
|
||||
x++;
|
||||
}
|
||||
}
|
||||
while (x<=10)
|
||||
{
|
||||
System.out.print(" "+x);
|
||||
while (x <= 10) {
|
||||
System.out.print(" " + x);
|
||||
x++;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,11 @@ package ejemplos;
|
|||
|
||||
public class Test_1 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
System.out.println("HOLA mundo");
|
||||
int x=1;
|
||||
x=2;
|
||||
x=3;
|
||||
x=4;
|
||||
int x = 1;
|
||||
x = 2;
|
||||
x = 3;
|
||||
x = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,12 @@ package ejemplos;
|
|||
|
||||
public class Test_2 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int x=1;
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
x++;
|
||||
++x;
|
||||
int y=0;
|
||||
x=x+y;
|
||||
int y = 0;
|
||||
x = x + y;
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,12 @@ package ejemplos;
|
|||
|
||||
public class Test_3 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int x=1;
|
||||
|
||||
if (x==1)
|
||||
x=2;
|
||||
x=3;
|
||||
x=4;
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
|
||||
if (x == 1)
|
||||
x = 2;
|
||||
x = 3;
|
||||
x = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,17 @@ package ejemplos;
|
|||
|
||||
public class Test_4 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int x=1;
|
||||
|
||||
if (x==1)
|
||||
{
|
||||
x=2;
|
||||
if (x>=1)
|
||||
{
|
||||
x=3;
|
||||
x=4;
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
|
||||
if (x == 1) {
|
||||
x = 2;
|
||||
if (x >= 1) {
|
||||
x = 3;
|
||||
x = 4;
|
||||
}
|
||||
}
|
||||
x=5;
|
||||
x=6;
|
||||
x = 5;
|
||||
x = 6;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,18 @@ package ejemplos;
|
|||
|
||||
public class Test_5 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int x=1;
|
||||
|
||||
if (x==1)
|
||||
{
|
||||
x=2;
|
||||
if (x>=1)
|
||||
{
|
||||
x=3;
|
||||
x=4;
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
|
||||
if (x == 1) {
|
||||
x = 2;
|
||||
if (x >= 1) {
|
||||
x = 3;
|
||||
x = 4;
|
||||
}
|
||||
x=5;
|
||||
x = 5;
|
||||
}
|
||||
x=6;
|
||||
x=7;
|
||||
x = 6;
|
||||
x = 7;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,16 @@ package ejemplos;
|
|||
|
||||
public class Test_6 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int x=1;
|
||||
|
||||
if (x==1)
|
||||
{
|
||||
x=2;
|
||||
x=3;
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
|
||||
if (x == 1) {
|
||||
x = 2;
|
||||
x = 3;
|
||||
} else {
|
||||
x = 4;
|
||||
x = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
x=4;
|
||||
x=5;
|
||||
}
|
||||
x=6;
|
||||
x = 6;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,21 +3,16 @@ package ejemplos;
|
|||
|
||||
public class Test_7 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int x=1;
|
||||
|
||||
if (x==1)
|
||||
{
|
||||
x=2;
|
||||
}
|
||||
else x=3;
|
||||
x=4;
|
||||
if (x==2)
|
||||
{
|
||||
x=5;
|
||||
}
|
||||
else if (x==3) x=6;
|
||||
x=7;
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
|
||||
if (x == 1) {
|
||||
x = 2;
|
||||
} else x = 3;
|
||||
x = 4;
|
||||
if (x == 2) {
|
||||
x = 5;
|
||||
} else if (x == 3) x = 6;
|
||||
x = 7;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,18 @@ package ejemplos;
|
|||
|
||||
public class Test_8 {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int x=1;
|
||||
|
||||
if (x==1)
|
||||
{
|
||||
x=2;
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
|
||||
if (x == 1) {
|
||||
x = 2;
|
||||
}
|
||||
x=5;
|
||||
x=6;
|
||||
if (x==2)
|
||||
{
|
||||
x=7;
|
||||
x = 5;
|
||||
x = 6;
|
||||
if (x == 2) {
|
||||
x = 7;
|
||||
}
|
||||
if (x==3) x=8;
|
||||
x=9;
|
||||
if (x == 3) x = 8;
|
||||
x = 9;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,29 +2,23 @@ package ejemplos;
|
|||
|
||||
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 2
|
||||
|
||||
int x=0;
|
||||
if (x>1)
|
||||
{
|
||||
x=1;
|
||||
while (x>2)
|
||||
{
|
||||
x=2;
|
||||
while (x>3)
|
||||
{
|
||||
x=3;
|
||||
if (x>4)
|
||||
{
|
||||
x=4;
|
||||
if (x>5)
|
||||
{
|
||||
x=5;
|
||||
|
||||
int x = 0;
|
||||
if (x > 1) {
|
||||
x = 1;
|
||||
while (x > 2) {
|
||||
x = 2;
|
||||
while (x > 3) {
|
||||
x = 3;
|
||||
if (x > 4) {
|
||||
x = 4;
|
||||
if (x > 5) {
|
||||
x = 5;
|
||||
}
|
||||
x--;
|
||||
}
|
||||
|
@ -34,8 +28,8 @@ public class Test_9 {
|
|||
}
|
||||
x--;
|
||||
}
|
||||
|
||||
|
||||
x--;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue