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

 

 


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


  Mostrar Temas
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 [14] 15 16 17 18 19 20 21 22 23
131  Programación / Java / Problema con Objeto en: 2 Abril 2011, 07:27 am
Buenas señores desde un Jframe trato de capturar 3 datos mmm a traves de un Jtextfield pero no em sale no se porque a ver ayudanme
Código
  1. import javax.swing.JButton;
  2. import javax.swing.JTextField;
  3.  
  4.  
  5. public class Frame extends javax.swing.JFrame {
  6.    public String Cad  ;
  7.    public int num;
  8.    public double Din;
  9.  
  10.    /** Creates new form Frame */
  11.   public Frame(String Cad, int num, double Din) {
  12.  
  13.        initComponents();
  14.        this.Cad = Cad;
  15.        this.num = num;
  16.        this.Din = Din;
  17.    }
  18.  
  19.  
  20.  
  21.  
  22.    public String getCad() {
  23.        return Cad;
  24.    }
  25.  
  26.    public void setCad(String Cad) {
  27.        this.Cad = Cad;
  28.    }
  29.  
  30.    public double getDin() {
  31.        return Din;
  32.    }
  33.  
  34.    public void setDin(double Din) {
  35.        this.Din = Din;
  36.    }
  37.  
  38.    public int getNum() {
  39.        return num;
  40.    }
  41.  
  42.    public void setNum(int num) {
  43.        this.num = num;
  44.    }
  45.  
  46.  
  47.  
  48.  
  49.    @SuppressWarnings("unchecked")
  50.    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  51.    private void initComponents() {
  52.  
  53.        jTextField1 = new javax.swing.JTextField();
  54.        jTextField2 = new javax.swing.JTextField();
  55.        jTextField3 = new javax.swing.JTextField();
  56.        jButton1 = new javax.swing.JButton();
  57.  
  58.        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  59.  
  60.        jTextField1.addActionListener(new java.awt.event.ActionListener() {
  61.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  62.                jTextField1ActionPerformed(evt);
  63.            }
  64.        });
  65.  
  66.        jButton1.setText("enviar");
  67.        jButton1.addActionListener(new java.awt.event.ActionListener() {
  68.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  69.                jButton1ActionPerformed(evt);
  70.            }
  71.        });
  72.  
  73.        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  74.        getContentPane().setLayout(layout);
  75.        layout.setHorizontalGroup(
  76.            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  77.            .addGroup(layout.createSequentialGroup()
  78.                .addGap(82, 82, 82)
  79.                .addComponent(jButton1)
  80.                .addContainerGap(94, Short.MAX_VALUE))
  81.            .addGroup(layout.createSequentialGroup()
  82.                .addGap(45, 45, 45)
  83.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  84.                    .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING)
  85.                    .addComponent(jTextField3)
  86.                    .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE))
  87.                .addGap(53, 53, 53))
  88.        );
  89.        layout.setVerticalGroup(
  90.            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  91.            .addGroup(layout.createSequentialGroup()
  92.                .addGap(57, 57, 57)
  93.                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  94.                .addGap(18, 18, 18)
  95.                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  96.                .addGap(18, 18, 18)
  97.                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  98.                .addGap(37, 37, 37)
  99.                .addComponent(jButton1)
  100.                .addContainerGap(95, Short.MAX_VALUE))
  101.        );
  102.  
  103.        pack();
  104.    }// </editor-fold>                        
  105.  
  106.    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
  107.        // TODO add your handling code here:
  108.  
  109.  
  110.    }                                          
  111.  
  112.    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  113.  
  114.        Cad=jTextField1.getText();
  115.        num=Integer.parseInt(jTextField2.getText());
  116.        Din=Double.parseDouble(jTextField3.getText());
  117.  
  118.    }                                        
  119.  
  120.    /**
  121.     * @param args the command line arguments
  122.     */
  123.  
  124.  
  125.    // Variables declaration - do not modify                    
  126.    private javax.swing.JButton jButton1;
  127.    private javax.swing.JTextField jTextField1;
  128.    private javax.swing.JTextField jTextField2;
  129.    private javax.swing.JTextField jTextField3;
  130.    // End of variables declaration                  
  131.  
  132. }
  133.  
  134.  


y este es mi main
Código
  1.  
  2. public class EjEmplo {
  3.  
  4.    public static void main(String[] args) {
  5.        String cadena;
  6.        Frame obj =new Frame ("maers",125,12.36);
  7.        obj.setVisible(true);
  8.        Hombre obj_1=new Hombre(obj.getCad() ,obj.getNum() ,obj.getDin());
  9.  
  10.    }
  11.  
  12. }
  13.  
  14.  
  15.  

en el main deseo que  ingrese los datos que yo e  ingresado por el textfiedl
132  Programación / Java / pasar de una JTextField en: 2 Abril 2011, 05:41 am
buenas señores tengo dos JTextField cuadno ingreso una cadena en una me debe copiar la cadena en otro JTextField cuando presione el boton enviar ....pero no me sale   a ver si me dan l amano :
Código
  1. private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
  2.        // TODO add your handling code here:
  3.        String cadena = "";
  4.  
  5.        cadena = jTextField1.getText();
  6.        jTextField2.setText(cadena);
  7.  
  8.    }
  9.  
133  Programación / Programación C/C++ / Error Fichero en: 1 Abril 2011, 17:13 pm
Buenas señores estoy trabajando con archivos de texto plano ...pero con este tipo de estructuras me sale todo bien.... lo unico que no me sale es cuando llamo al fichero e ingresoi nuevos reportes chanca los datos que hay ,lo que  deberia hacer es  ingresar y lguardarlos  cpon los anteriores a ver si me dan una mano y me dicen el error
Código
  1. # define DELIM_C "@"
  2. # define DELIM_R "*"
  3.  
  4. //-------------------------------------------------//
  5. //-------------------------------------------------//
  6.  
  7. #include <stdio.h>
  8. #include <iostream>
  9. #include <conio.h>
  10. # include <io.h>
  11. # include <fcntl.h>
  12. # include <sys\stat.h>
  13.  
  14.  
  15. //-------------------------------------------------//
  16. //-------------------------------------------------//
  17.  
  18. using namespace std;
  19.  
  20. int fichero;
  21. char nom[10];
  22. int edad;
  23. char nombre[10];
  24.  
  25. //-------------------------------------------------//
  26. //-------------------------------------------------//  
  27.  
  28. void crear(char nombre[30])
  29. {
  30. fichero= creat( nombre , S_IWRITE | S_IREAD );
  31.  
  32. if ( fichero < 0 )
  33.    {
  34.      printf(" El Archivo No se Pudo crear !!! ");
  35.       getch();
  36.      return;    
  37.    }
  38.  
  39. else
  40.    printf(" \t\t\t El Archivo Se Creo Correctamente !!!! ");  
  41.     getch();
  42. }
  43.  
  44. //-------------------------------------------------//
  45. //-------------------------------------------------//
  46.  
  47.  
  48. void abrir(char nombre[30])
  49. {
  50. fichero = open ( nombre , O_RDWR);
  51.  
  52.   if ( fichero < 0 )
  53.      printf(" El Archivo No se Pudo Abrir !!! ");
  54. }
  55.  
  56. //-------------------------------------------------//
  57. //-------------------------------------------------//
  58.  
  59. void escribir(int N)
  60. {
  61. abrir(nombre);
  62. printf("\n");
  63. printf("\t Ingrese sus Datos ......  \n");
  64. getch();
  65.  
  66. for(int j=1;j<=N;j++)
  67.   {
  68.    fflush(stdin);
  69.    cout<<endl;
  70.    printf("  -->  Ingrese Nombre   : ");
  71.    fflush(stdin);
  72.    gets(nom);
  73.  
  74.    printf("  --> Ingrese Edad     : ");
  75.    fflush(stdin);
  76.    cin>>edad;
  77.    fflush(stdin);
  78.  
  79.  
  80.    write( fichero, nom , strlen(nom) );
  81.    write( fichero , DELIM_C , 1 );
  82.    write( fichero , &edad , 2 );
  83.    write( fichero, DELIM_R , 1 );
  84.  }
  85.  
  86.  close(fichero);
  87.  
  88. }
  89.  
  90. //-------------------------------------------------//
  91. //-------------------------------------------------//
  92.  
  93. void leer()
  94. {
  95.  char K;
  96.  int i = 0;
  97.   printf("\nTeclee El nombre del Fichero a Acceder ");
  98.   fflush(stdin);
  99.   gets(nombre);
  100.   abrir(nombre);
  101.  
  102.  while ( read ( fichero , &K , 1 ) > 0 )
  103.        {
  104.         if( K == '*' )  
  105.           {
  106.            printf("\t\t    ");
  107.            printf("\n");
  108.            continue;
  109.           }
  110.  
  111.         if( K == '@' )  
  112.           {
  113.           printf("  ");
  114.            read(fichero,&edad,2);
  115.            cout<<edad;
  116.           continue;
  117.           }
  118.  
  119.            cout<<K;
  120.        }
  121. getch();
  122. close(fichero);
  123.  
  124. }
  125. //-------------------------------------------------//
  126. //-------------------------------------------------//
  127.  
  128. void menu()
  129. {
  130.  printf("\n");
  131.  system("cls");  
  132.  printf("\n");
  133.  system("color a");
  134.  printf("\t ÈÍÍÍÍÍÍÍÍÍÍÍÍ<< Reguistros de Longitud Variable >>ÍÍÍÍÍÍÍÍÍÍͼ\n");
  135.  printf("\n\t\t º º     MENU           ");
  136.  printf("\n\t\t º º                      ");
  137.  printf("\n\t\t º º1.  Crear fichero            ");
  138.  printf("\n\t\t º º2.  Insertar datos         ");
  139.  printf("\n\t\t º º3.  Abrir y leer datos Guardados             ");
  140.  printf("\n\t\t º º4.  Salir           \n");
  141.  printf("\t\t º º\n");
  142.  printf("\t\t ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ\n");
  143.  
  144. }
  145.  
  146.  
  147. //-------------------------------------------------//
  148. //-------------------------------------------------//
  149.  
  150.  
  151. int main()
  152. {
  153.  
  154.  
  155. int N;
  156.  
  157. int opcion;  
  158. menu();
  159.  
  160. while(1)
  161. {
  162.   printf("\n\n");
  163.  
  164.   printf("\n");
  165.   for(int j=0;j<10;j++)
  166.   {
  167.   menu();
  168.   }
  169.   //leer();
  170.  
  171.   do
  172.    {
  173.  
  174.     printf("\n\n   -> Ingrese una Opcion");
  175.     printf("      --------------->  ");
  176.     cin>>opcion;
  177.  
  178.    }
  179.  
  180.  while(opcion < 1 || opcion > 4);
  181.  
  182. switch (opcion)
  183. {
  184.  case 1:      
  185.            printf("\n\tIngrese el nombre del Fichero ");
  186.             fflush(stdin);
  187.            gets(nombre);
  188.            crear(nombre);
  189.            break;
  190.  
  191.  case 2:
  192.            cout<<endl<<"   - Cantidad de Datos : ";
  193.            cin>>N;
  194.            escribir(N);
  195.            break;
  196.  
  197.  case 3:
  198.            leer();
  199.            break;
  200.  
  201.  case 4:
  202.  
  203.            printf("\n\t      *****  Se Guardaran los cambios ****" );
  204.            printf("\n\n\n");
  205.            getch();
  206.           exit(0);
  207.            break;
  208.   default:
  209.           printf("\nopcion no valida");
  210. }
  211. }
  212.  
  213. printf("\n\n\n");
  214.  
  215. system("pause");
  216. }
  217.  
  218. //-------------------------------------------------//
  219. //-------------------------------------------------//
  220.  
  221.  




134  Programación / Programación C/C++ / socket en C en: 28 Marzo 2011, 09:38 am
Buenas señores disculpen no tendran algun manual o algun tutorial sobre socket en C
e estado buscando en el diosgoogle pero nada estan en ingles :S a ver si  tiene uno en español ...................
135  Programación / Programación C/C++ / ficheros en listas enlazadas en: 28 Marzo 2011, 07:50 am
Buenas señores tengo una duda haber .............con arreglo de estructuras se que se usa en algunos casos sizeof(buffer) para conoces el tamaño del arreglo que poseen todas las estructuras .ya ahora mi duda es  se usa el mismo sizeof(buffer) en una lista enlazada o no es necesiro o se usa otro metodo mmmm.........
136  Programación / Programación C/C++ / Interprete en: 23 Marzo 2011, 07:57 am
bueanas señores del foro estoy empezando a hacer un pequeño interprete ........lo amlo esque no se porque se salta de la sentencia :
if(frase[patron]=='e' && frase[patron+1]=='l' && frase[patron+2]=='s' && frase[patron+3]=='e' )

justo cunando ingreso 1aelse;
me deve de salir en  pantalla:

identidicador entero else

else e if son palabras reservdas que  de a cuerdo al analisis que le doy me deve ingresar a la comparacion pero no se porqeu no entra en ese ejemplo me sale

identidicador / entero /identificador

no entiendo orque a que se deve a ver denle una ojeada
Código
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int patron=0;
  5. int i=0,j=0,factor=0;
  6. char frase[100];
  7. //------------------------------------------------------//
  8. void entero();
  9. void identificador();
  10. void entero_identificador();
  11. //------------------------------------------------------//
  12. int main()
  13. {
  14.  
  15. cout<<"ingrese frase "<<endl;
  16. cin>>frase;
  17. int n=strlen(frase);
  18. cout<<endl;
  19. while(n!= patron)
  20.    {
  21.  
  22.       if(frase[patron]==';')
  23.       {
  24.          if(i!=0)
  25.          {
  26.           cout<<"entero "<<"/";
  27.           }
  28.           if(j!=0)
  29.           {
  30.           cout<<"identificador"<<"/";
  31.           }
  32.  
  33.        cin.ignore();
  34.    cin.get ();
  35.  
  36.       }
  37. if(frase[patron]=='i' && frase[patron+1]=='f')
  38. {
  39.                 if(j!=0)
  40.                {
  41.                 cout<<"identificador"<<"/";
  42.                 i=0;
  43.                 j=0;
  44.                 }
  45.  
  46.                if(i!=0)
  47.                {
  48.                 cout<<"entero"<<"/";
  49.                 i=0;
  50.                 j=0;
  51.                 }              
  52. cout<<"if"<<" /";
  53. patron=patron+2;
  54.                  continue;
  55. }
  56.  
  57. if(frase[patron]=='e' && frase[patron+1]=='l' && frase[patron+2]=='s' && frase[patron+3]=='e' )
  58. {    
  59.                if(j!=0)
  60.                {
  61.                 cout<<"identificador "<<"/";
  62.                 i=0;
  63.                 j=0;
  64.                 }
  65.  
  66.                if(i!=0)
  67.                {
  68.                 cout<<"entero "<<"/";
  69.                 i=0;
  70.                 j=0;
  71.                 }
  72.  
  73. cout<<"else"<<" /";
  74. patron=patron+4;
  75. continue;
  76.  
  77. }
  78.  
  79. if(isdigit(frase[patron])!=0)
  80. {
  81. identificador();
  82. patron++;
  83. }
  84. if(isdigit(frase[patron])==0)
  85. {
  86. entero();
  87. patron++;
  88. }
  89.  
  90.  
  91. }
  92.  
  93. }
  94.  
  95. //------------------------------------------------------//
  96. //------------------------------------------------------//
  97.  
  98. void identificador()
  99. {
  100. if(j==0)
  101. {
  102. i++;
  103. }
  104.  
  105. if(j!=0)
  106. {
  107. cout<<"identificador "<<"/";
  108. j=0;
  109. i++;
  110.    }
  111.  
  112.  
  113. }
  114.  
  115. //------------------------------------------------------//
  116. //------------------------------------------------------//
  117. void entero()
  118. {
  119. if(i==0)
  120. {
  121. j++;
  122. }
  123. if(i!=0)
  124. {
  125. cout<<"entero "<<"/";
  126. i=0;
  127. j++;
  128. }
  129. }
  130.  
  131.  
137  Programación / Programación C/C++ / Funcion isdigit en: 17 Marzo 2011, 06:05 am
buenas señores necesito qe me aclaren una duda con esta funcion estoy creando un programa en el que ingrese una cadena de caracteres y me bote lo siguientes:
"asd39n"       345     34.455     A345
cadena        entero    flotante     identificador

pero no se algo esta mal que no me da lo qu e yo quiero a ver denlñe una ojeada  mi code :D gracias
Código
  1. //------------------------------------------------------//
  2. //------------------------------------------------------//
  3. #include <iostream>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. #include <ctype.h>
  8. #include <iomanip.h>
  9. using std::cout;
  10. using std::endl;
  11. #include <cstring>
  12. int ident=0;
  13. //------------------------------------------------------//
  14. //------------------------------------------------------//
  15. void cadena_caracteres(char *sub_cadena );
  16. void numero_entero(char *sub_cadena);
  17. void numero_flotante(char *sub_cadena);
  18. void identificador (char *sub_cadena);
  19. //------------------------------------------------------//
  20. //------------------------------------------------------//
  21. int main()
  22. {
  23.  char frase[100];
  24.  char *sub_cadena=NULL;
  25. cout<<"ingrese la frase a evaluar    ";
  26. gets(frase);
  27.  sub_cadena = strtok(frase," ");
  28.  while(sub_cadena!= NULL)
  29.    {
  30.      cout << sub_cadena << " ------> ";
  31. //------------------------------------------------------//
  32.      if(sub_cadena[0]=='"')
  33.      {
  34.        cadena_caracteres(sub_cadena);
  35.  
  36.      }
  37. //------------------------------------------------------//
  38.     for(int j=0;j<strlen(sub_cadena);j++)
  39.      {
  40.              if(sub_cadena[j]=='.')
  41.              {
  42.                 numero_flotante(sub_cadena);
  43.                 ident=j;
  44.                 break;
  45.              }
  46.      }
  47. //------------------------------------------------------//
  48.  
  49.  if( isdigit(sub_cadena[0])!=0 && isdigit(sub_cadena[ident])!=0)
  50.      {
  51.            numero_entero(sub_cadena);
  52.  
  53.      }
  54. //------------------------------------------------------//
  55. if( isdigit(sub_cadena[0])!=0)
  56.      {
  57.            identificador(sub_cadena);
  58.  
  59.      }
  60. //------------------------------------------------------//
  61.      sub_cadena = strtok(NULL, " ");
  62.    }
  63.  system("pause");
  64. }
  65.  
  66. //------------------------------------------------------//
  67. //------------------------------------------------------//
  68.  
  69. void cadena_caracteres(char *sub_cadena)
  70. {
  71. int n=strlen(sub_cadena);
  72. if(sub_cadena[n-1]=='"')
  73. {
  74.    cout<<endl;
  75.    cout<<setw (25)<<"ES UNA CADENA DE CARACTERES"<<endl;  
  76. }  
  77. // else { cout<<endl;cout<<setw (25)<<"PARECIA  UNA CADENA DE CARACTERES PERO NO LO ES "<<endl;  }  
  78. }
  79. //------------------------------------------------------//
  80. //------------------------------------------------------//
  81. void numero_entero(char *sub_cadena)
  82. {
  83.   int x=0;  
  84.    for(int i=0;i<strlen(sub_cadena);i++)  
  85.    {
  86.     if(isdigit(sub_cadena[i]))
  87.       {
  88.         x++;
  89.       }
  90.    }  
  91.  
  92.    if(x==strlen(sub_cadena))  
  93.    {
  94.      cout<<endl;cout<<setw (25)<<"ES UN NUMERO ENTERO "<<endl;
  95.    }
  96.    //else {cout<<endl;cout<<setw (25)<<"ESTO NO ES UN NUMERO ENTERO "<<endl;}
  97.  
  98. }
  99.  
  100. //------------------------------------------------------//
  101. //------------------------------------------------------//
  102.  
  103. void numero_flotante(char *sub_cadena)
  104. {
  105.     int x=0,y=0;
  106. for(int i=0;i<strlen(sub_cadena);i++)  
  107.    {
  108.     if(isdigit(sub_cadena[i]))
  109.       {
  110.         x++;
  111.       }
  112.       if(sub_cadena[i]=='.')
  113.              {
  114.               y++;
  115.              }
  116.    }  
  117.  
  118.    if(x==strlen(sub_cadena)-1 &&  y==1)
  119.    {
  120.     cout<<endl;cout<<setw (25)<<"ES UN NUMERO FLOTANTE "<<endl;
  121.    }
  122.   // else {cout<<endl;cout<<setw (25)<<"ESTO NO ES UN NUMERO FLOTANTE "<<endl;}
  123. }
  124. //------------------------------------------------------//
  125. //------------------------------------------------------//
  126.  
  127. void identificador (char *sub_cadena)
  128. {
  129.     int x=0,y=0;
  130.  
  131. for(int i=0;i<strlen(sub_cadena);i++)  
  132.    {
  133.         if(isdigit(sub_cadena[i])!=0)
  134.         {
  135.          x++;
  136.         }
  137.          if(isdigit(sub_cadena[i])==0)
  138.         {
  139.          x++;
  140.         }
  141.     }
  142.  
  143.         if(isdigit(sub_cadena[0])==0 && x+y==strlen(sub_cadena))
  144.         {cout<<endl;cout<<setw (25)<<"ESTO ES UN IDENTIFICADOR  "<<endl;}
  145. }
  146.  
  147.  
138  Programación / Programación General / Notepad en: 16 Marzo 2011, 05:29 am
buenas señores disculpen la molestia necesito saber la estructura interna del notepad y si se puede del word y del excel "!"!"! lo estaba buscando por google pero no encontre nada a ver si me dan una manita
139  Programación / Programación General / haskell en: 14 Marzo 2011, 08:32 am
buena señores desearia  que me ayudaran con la gramatica de haskell la necesito para poder estudiarla estaba buscando por la red pero no encontre nada ayudenme.....
140  Programación / Programación General / organizacion de archivos en: 14 Marzo 2011, 03:30 am
buenas señores del foro quisiera que me ayudaran a que me digan porfavor en que consites la estructura interna del formato  .doc .txt .pdf ........sus cabezeras su cuero y su cola.............gracias de antemano
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 [14] 15 16 17 18 19 20 21 22 23
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines