Código de Java - Dibujo del Árbol de navidad con asteriscos

Versión 1
estrellaestrellaestrellaestrellaestrella(4)

Publicado el 14 de Enero del 2018gráfica de visualizaciones de la versión: Versión 1
19.460 visualizaciones desde el 14 de Enero del 2018
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

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
public class ArbolNavidad
{
	public static void main(String args[])
	{
		int max=20;
		int j=1,k=0;
 
		// primer arbol
 
		System.out.println();
		for(int i=0;i<=max;i+=2)
		{
			int spc=(5+(int)Math.ceil(max/2)-j);
			String spaces=new String(new char[spc]).replace("\0"," ");
			String asteri=new String(new char[i+1]).replace("\0","*");
			System.out.println(spaces+asteri);
			j++;
		}
 
		// tronco
		if(max>=7)
		{
			int spc=(5+(int)Math.ceil(max/2)-2);
			String spaces=new String(new char[spc]).replace("\0"," ");
			String asteri=new String(new char[3]).replace("\0","*");
			System.out.println(spaces+asteri);
			System.out.println(spaces+asteri);
		}
		System.out.println();
 
		// segundo Arbol
 
		j=1;
		for(int h=1;h<3;h++)
		{
			for(int i=k;i<=max;i+=2)
			{
				int spc=(5+(int)Math.ceil(max/2)-j);
				String spaces=new String(new char[spc]).replace("\0"," ");
				String asteri=new String(new char[i+1]).replace("\0","*");
				System.out.println(spaces+asteri);
				j++;
			}
			k=5;
			j=3;
		}
 
		// tronco
		if(max>=7)
		{
			int spc=(5+(int)Math.ceil(max/2)-2);
			String spaces=new String(new char[spc]).replace("\0"," ");
			String asteri=new String(new char[3]).replace("\0","*");
			System.out.println(spaces+asteri);
			System.out.println(spaces+asteri);
		}
		System.out.println();
	}
}



Comentarios sobre la versión: Versión 1 (4)

jojosama
15 de Enero del 2018
estrellaestrellaestrellaestrellaestrella
Hola sabes como puedo poner otro boton en un String name=JOptionPane.showInputDialog();
o un JOptionPane
Responder
Imágen de perfil
23 de Enero del 2018
estrellaestrellaestrellaestrellaestrella
Gracias Bro1
Responder
elvis
1 de Noviembre del 2018
estrellaestrellaestrellaestrellaestrella
chebre bro te isiste una
Responder
FrDvlpr
30 de Septiembre del 2021
estrellaestrellaestrellaestrellaestrella
triagulo resumido

class arbol{

arbol(){

for(int i=0; i<10; i++){

for(int j=0; j<10-i; j++){

System.out.print(" ");
}

for(int k=0; k<2*i+1; k++){

System.out.print("*");
}

System.out.println("");
}
}
}
Responder

Comentar la versión: Versión 1

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s4385