elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


  Mostrar Mensajes
Páginas: 1 ... 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 [63] 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
621  Programación / Java / Re: dibujar un arbol de navidad con bucles for en: 15 Diciembre 2009, 02:38 am
conformate con la estrella por que modificarlo es algo tedioso :¬¬

PD: utilizas las etiquetas para code

Código
  1. public class Arbol {
  2. public static void main(String[] args) {
  3.        String c = "* ";
  4.        String b = "  ";
  5.        int altura = 20;
  6.        int ancho = 1;
  7.        String n = "/";
  8.        String x= "";
  9.        String y = " ";
  10.        for (int i = 0; i < 1; i++){
  11.        if(i==0){
  12.           for (int k = 0; k < altura - i-1; k++)System.out.print(b);
  13.             System.out.print(" /\\ \n");
  14.            }
  15.            for (int k = 0; k < altura - i-1; k++)
  16.            System.out.print(b);
  17.            System.out.print(""+x+n+""+y+""+y+"\\");x+=" ";y+=" ";
  18.           System.out.print("\n");
  19.        }
  20.        for (int k = 0; k < altura-3; k++)
  21.        System.out.print(b);
  22.        System.out.println("~~~~"+"    "+"~~~~");
  23.        for (int k = 0; k < altura-3; k++)System.out.print(b);
  24.        System.out.println("\\          /");
  25.        for (int k = 0; k < altura-3; k++)System.out.print(b);
  26.        System.out.println("/          \\");
  27.        for (int k = 0; k < altura-4; k++)System.out.print(b);
  28.        System.out.println(" /____    ____\\");
  29.        for (int i = 0; i < altura/4; i++){
  30.            for (int k = 0; k < altura - i; k++){
  31.                System.out.print(b);
  32.            }
  33.            for (int j = 0; j < i*2 + ancho; j++){
  34.                System.out.print(c);
  35.            }
  36.            System.out.print("\n");
  37.        }
  38.         for (int i = 0; i < altura/4; i++){
  39.            for (int k = 0; k < (altura - i) - 2; k++){
  40.                System.out.print(b);
  41.            }
  42.            for (int j = 0; j < i*2 + 5; j++){
  43.                System.out.print(c);
  44.            }
  45.            System.out.print("\n");
  46.        }
  47.        for (int i = 0; i < altura/4; i++){
  48.            for (int k = 0; k < (altura - i) - 4; k++){
  49.                System.out.print(b);
  50.            }
  51.            for (int j = 0; j < i*2 + 9; j++){
  52.                System.out.print(c);
  53.            }
  54.            System.out.print("\n");
  55.        }
  56.        for (int i = 0; i < altura/4; i++){
  57.            for (int k = 0; k < (altura - i) - 6; k++){
  58.                System.out.print(b);
  59.            }
  60.            for (int j = 0; j < i*2 + 13; j++){
  61.                System.out.print(c);
  62.            }
  63.            System.out.print("\n");
  64.        }
  65.        for (int i = 0; i < altura/4; i++){
  66.            for (int k = 0; k < altura -2; k++){
  67.                System.out.print(b);
  68.            }
  69.            for (int j = 0; j < 5; j++){
  70.                System.out.print(c);
  71.            }
  72.            System.out.print("\n");
  73.        }
  74.    }
  75. }
622  Programación / Java / Re: Calculo Integral en: 15 Diciembre 2009, 00:21 am
 :-\ no conozco una libreria para eso creo que no la hay todo desde 0 diria yo

SL2
623  Programación / Java / Re: que estructura de datos me recomendais para guardar 70.000 objetos? en: 15 Diciembre 2009, 00:16 am
HashSet deprocated  :o lo dudo, podrias usarlo asi como tambien un vector

SL2
624  Programación / Java / Re: archivo ingresar, buscar txt en: 14 Diciembre 2009, 02:23 am
 :o 2 semanas  :xD :xD  como que te falta mucho  para aprender jeje bueno para lo que dices bufferedWriter.newLine(); para que guardas en forma vertical.
625  Programación / Java / Re: archivo ingresar, buscar txt en: 13 Diciembre 2009, 02:52 am
si me ubieras colocado el code desde el inicio te lo ubiera solucionado en 2 min asi esto no estubiera asi ademas si no quieres copiar y pegar podria hacerlo y te lo comento para que entiendas el procedimiento eso es lo mas que puedo hacer .por que tu solo asi como asi no podras eso es seguro. ya con todo lo que te he dicho ya es mas que suficiente para solucionar tu problema que no lo veas es por tu falta de conocimiento en el tema.y explicartelo mm ya con lo que dije de "variable de instancia" esa es la clave para la solucion.

SL2
626  Programación / Java / Re: archivo ingresar, buscar txt en: 13 Diciembre 2009, 02:35 am
 :¬¬ :¬¬ claro que te sirve que no lo sepas implementar es otra cosa
627  Programación / Java / Re: archivo ingresar, buscar txt en: 12 Diciembre 2009, 23:19 pm
tienes que colocarlo como variable de instancia en la clase :¬¬
628  Programación / Java / Re: archivo ingresar, buscar txt en: 12 Diciembre 2009, 23:08 pm
  :P como te dije anteriormente tienes que sacar
   try {
         BufferedWriter bufferedWriter= new BufferedWriter(
               new FileWriter("c:\\archivo.txt"));

de la accion de guardar
629  Programación / Java / Re: archivo ingresar, buscar txt en: 12 Diciembre 2009, 22:26 pm
tienes que cambiar la ruta es decir en linux es /home/tuUsuario/archivo.txt  en Windows seria C:\archivo.txt.

lo mas seguro es que estas colocando en un ciclo la creacion del
  BufferedWriter bufferedWriter= new BufferedWriter(
               new FileWriter("/home/leyer/n.txt"));

solo tienes que hacer uno en todo el programa y no cada vez que le des guardar.

por fecha de nacimiento modifica el code anterior coloca esto

Código
  1. if(read.substring(read.indexOf(" "),read.lastIndexOf(" ")).trim().equals(request)){ }

Para buscar por nombre

Código
  1. if(read.indexOf("Jonh")!=-1){}
630  Programación / Java / Re: archivo ingresar, buscar txt en: 12 Diciembre 2009, 21:35 pm
para guardar en el archivo sin sobreescribir
Código
  1. try {
  2. BufferedWriter bufferedWriter= new BufferedWriter(
  3. new FileWriter("/home/leyer/n.txt"));
  4. bufferedWriter.append("Jonh 1990 19");
  5. bufferedWriter.flush();bufferedWriter.newLine();
  6. bufferedWriter.append("Maria 1991 18");
  7. bufferedWriter.flush();bufferedWriter.newLine();
  8. } catch (IOException e) {
  9. // TODO Auto-generated catch block
  10. e.printStackTrace();
  11. }

//Buscar por edad y leer

Código
  1. try {
  2. //Buscar y leer
  3. BufferedReader bufferedReader = new BufferedReader(new FileReader("/home/leyer/n.txt"));
  4. String read = " ";
  5. String request = "19"; //Text a buscar
  6. while((read=bufferedReader.readLine()) != null){
  7. if(read.substring(read.lastIndexOf(" ")).trim().equals(request))
  8. System.out.println("-"+read);
  9.  
  10. }
  11. } catch (FileNotFoundException e) {
  12. // TODO Auto-generated catch block
  13. e.printStackTrace();
  14. } catch (IOException e) {
  15. // TODO Auto-generated catch block
  16. e.printStackTrace();
  17. }
Páginas: 1 ... 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 [63] 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines