Initial commit

This commit is contained in:
Carlos Galindo 2019-03-26 20:11:14 +01:00
commit a52d26a18e
Signed by untrusted user who does not match committer: kauron
GPG key ID: 83E68706DEE119A3
24 changed files with 1091 additions and 0 deletions

View file

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

View file

@ -0,0 +1,24 @@
package ejemplos;
public class Bucles_2 {
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);
y++;
}
x++;
}
System.out.println();
}
}

View file

@ -0,0 +1,37 @@
package ejemplos;
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();
// BUCLE WHILE (sin anidamiento)
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);
x++;
}
while (x<=10);
System.out.println();
}
}

View file

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

View file

@ -0,0 +1,52 @@
package ejemplos;
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();
// 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);
y++;
}
x++;
}
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);
}
x++;
}
while (x<=10);
System.out.println();
}
}

View file

@ -0,0 +1,27 @@
package ejemplos;
public class Bucles_6 {
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);
x++;
while (x<=10)
{
System.out.print(" "+x);
x++;
}
}
while (x<=10)
{
System.out.print(" "+x);
x++;
}
System.out.println();
}
}

View file

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

View file

@ -0,0 +1,14 @@
package ejemplos;
public class Test_2 {
public static void main(String[] args)
{
int x=1;
x++;
++x;
int y=0;
x=x+y;
System.out.println(x);
}
}

View file

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

View file

@ -0,0 +1,21 @@
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;
}
}
x=5;
x=6;
}
}

View file

@ -0,0 +1,22 @@
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;
}
x=5;
}
x=6;
x=7;
}
}

View file

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

View file

@ -0,0 +1,23 @@
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;
}
}

View file

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

View file

@ -0,0 +1,41 @@
package ejemplos;
public class Test_9 {
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;
}
x--;
}
x--;
}
x--;
}
x--;
}
x--;
}
}