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 Temas
Páginas: [1]
1  Foros Generales / Dudas Generales / Contratar un buen servicio de hosting en: 16 Mayo 2016, 07:47 am
hola hoy me encontre con esta empresa de hosting quiero contratar uno de hay pero no se si este bien hacerlo en esa pagina
Código:
https://alipreethost.net/
2  Programación / Java / problemas con entender el tema en Java en: 7 Marzo 2016, 02:36 am
ayuda porfavor el siguiente programa no me corre quisiera saber que error estoy cometiendo?


Código
  1. class Abundantes extends Thread{
  2. public static void main(String args[]) {
  3. long tini, tfin, ttarda;
  4. //Abundantes obj = new Abundantes();
  5. tini=System.currentTimeMillis();
  6. //obj.mostrar_abundantes(10);
  7. ttarda=tfin-tini;
  8. System.out.println("Tardo: "+ttarda);
  9. }
  10. private boolean es_abuntantes(long x){
  11. long i, suma=0;
  12. for(i=1;i<=x;i++){
  13. if(x%i==0){
  14. System.out.println("+ "+i);
  15. suma+=i; //sumar = suma+i;
  16. }
  17. }
  18. System.out.println();
  19. System.out.println(suma+"> 2*"+x);
  20. if(suma>2*x) return true;
  21. else return false;
  22. }
  23. public void run(){
  24. int n;
  25. while(n<1){
  26. if(es_abuntantes(n)){
  27. System.out.println(n+"es abundate");
  28. n--;
  29. }
  30. }
  31. }
  32. }
  33.  
  34.  
  35.  
  36. class Gemelos extends Thread{
  37. public static void main(String loquiequiera[]){
  38. long inicio_pri, fin_pri, mili_pri;
  39. //Gemelos a = new Gemelos();
  40. //a.saludar();
  41. inicio_pri=System.currentTimeMillis();
  42. //a.Mostrar_n_gemelos(10);
  43. fin_pri=System.currentTimeMillis();
  44. mili_pri=fin_pri - inicio_pri;
  45. System.out.println("MILISEGNDOS=" + mili_pri);
  46.  
  47. }
  48.  
  49. private boolean primo(long num_a_chk){
  50. int divisibles=0;
  51. for(long con_quien=num_a_chk; con_quien>=1; con_quien--){
  52. if(num_a_chk%con_quien == 0 ) divisibles++;
  53. }
  54. if( divisibles==2 )
  55. return true;
  56. else
  57. return false;
  58. }
  59.  
  60. public void run(){
  61. int n=100;
  62. long num_a_chk=3, encontrados=0;
  63. while(encontrados<n){
  64. if(primo(num_a_chk)==true && primo(num_a_chk-2) == true ){
  65. System.out.println("Gemelos: "+ (num_a_chk-2) + " , " + num_a_chk);
  66. encontrados++;
  67. }
  68. num_a_chk++;
  69. }
  70. }
  71. }
  72.  
  73. public class Juntos01 {
  74. public static void main(String arg[]){
  75. Gemelos a = new Gemelos();
  76. Abundantes b = new Abundantes();
  77. a.start();
  78. b.start();
  79. }
  80. }
  81.  
  82.  


Mod: Los códigos deben ir en etiquetas GeSHi, los temas d jaa van en s repecivo foro
3  Programación / Programación C/C++ / ayuda con punteros a estructura en: 12 Febrero 2016, 04:33 am
ayuda necesito saber como hacer para que muestre la direccion de memoria
/*11. Dado un arreglo de 10 elementos ={1, 2, 3, 4, 4, 7, 8, 9, 5, 4},
escribir un programa en C  (haciendo uso de puntero) que muestre las
direcciones de memoria de cada elemento del arreglo.*/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#define TAM 20
typedef struct Numeros{ //definimos el tipo de dato con typedef
   int vector;
   struct Numeros *next;
       struct Numeros *atras;
}DATOS;

DATOS *base, *one, *p;
int opc, busca, r, caux, i, j, J;
int mas=0;
char op;

void agregar();
void mostrar(DATOS *ptr);
void pornumero(DATOS *ptr);
int main(){
   do{
      system("reset");
      printf("------menu------\n");
      printf("A - ingrese los 10 datos\n");
      printf("B - mostrar los numeros\n");
      printf("S - salir\n");
      printf("escoja una opcion\n");
      scanf("%c",&opc);
      opc=toupper(opc);
      switch(opc){
         case 'A' :   agregar(p);
         break;
         case'B' :
            system("clear");
              if(one!=NULL){             //valida si hay datos o no
                J=0;
                p=one;
               setbuf(stdin,NULL);
               for(i=0;p!=NULL;i++)  {       //ciclo que llama a funcion mostrar()
                  mostrar(p);
                  p=p->next;
                  J++;
                  if(J>=4){
                     
                     J=0;
                     printf("\t\t VER SIGUIENTES....");
                     getchar();
                     getchar();
                     system("clear");
                  }   
               }
               printf("\n\t PRESIONE UNA TECLA PARA CONTINUAR..."); }
               else{
                  printf("\n\n No existen registros actualmente para mostrar.");
               }
               getchar();
               getchar();
            break;
         break;
      }
   }while(opc!='S');    //fin de ciclo menu principal
   return 0;

}
void agregar(void){
   for(i=0;i<10;i++,j++) {       //ciclo para agregar datos y llevar registro de datos introducidos.
      system("clear");
      base=(DATOS *) malloc(sizeof(DATOS)); //puntero a bloque
      printf("datos la posicion %d : ",mas++);
      scanf("%d",&base->vector);
      setbuf(stdin,NULL);
      if(one==NULL){   
         one=base;
         base->next=NULL;
      }
      else{
         base->next=one;
         one=base;
      }
   }
}

void mostrar(DATOS *ptr){
   printf("\n # valor: %d",ptr->vector);
}    
4  Programación / Programación C/C++ / problema con manejo de nodos en linux en: 10 Febrero 2016, 20:12 pm
ayuda tengo un problema con este codigo al compilar en gcc

#include<stdio.h>
#include<stdlib.h>


void insertarnodoinicio();
void insertarnodoalfinal();
void insertarentrenodos();
void eliminarnodoinicio();
void eliminarnodofinal();
void eliminarentredosnodos();
void buscarnumero();
void mostrarnodo();


struct dato{
  dato *psig;
  int numero;
};

      dato *cab=NULL;
      dato *n=NULL;
      dato *aux=NULL;
      dato *p=NULL;
      dato *q;
      int x,pos,numerodenodos=0,opc;
      
      main()
      {
            do{
                  printf("\n************************* ELIGE UNA OPCION **********************************\n\n");
                  printf("                   1.-Insertar Un Nodo al Inicio\n");
                  printf("                   2.-Insertar Un Nodo al Final\n");
                  printf("                   3.-Insertar entre dos Nodos\n");
                  printf("                   4.-Mostrar Lista\n");
                  printf("                   5.-Buscar Nodo\n");
                  printf("                   6.-Eliminar Nodo al Inicio\n");
                  printf("                   7.-Eliminar Nodo Final\n");
                  printf("                   8.-Eliminar Entre dos nodos\n");
                  printf("                   9.-Salir\n");      
                  printf("\n\nTeclee su opcion: ");
                  scanf("%d",&opc);
                                    
                  switch(opc){
                              case 1:
                              insertarnodoinicio();
                              break;
                                                    
                              case 2:
                              insertarnodoalfinal();
                              break;
                                                
                              case 3:
                              insertarentrenodos();
                              break;
                                                    
                              case 4:    
                              mostrarnodo();
                              break;
                              
                              case 5:
                              buscarnumero();
                              break;
                              
                              case 6:
                              eliminarnodoinicio();
                              break;
                              
                              case 7:
                              eliminarnodofinal();
                              break;
                              
                              case 8:
                              eliminarentredosnodos();
                              break;
                              
                              case 9:
                              exit(0);break;              
                              
                              default:
                              printf("Opcion no valida");break;    
                           }
                              
                                    }while(opc!=9);
                                    getch();
                                    
                                      
                                    }
                            
                            
                            
void eliminarentredosnodos()
{
     q=cab;
     int h=1;
     if (cab=NULL)
    
                  printf("La lista esta vacia");
                  
                  
              else
                  {
             printf("Ingrese Nodo a eliminar: ");
             scanf("%d",&x);
             while (q->numero!=x && h==1)
             {
             if (q->psig!=NULL)
             {
                               p=q;
                               q=q->psig;
                               }                                              
             else
                  
             h=0;
             }
                  if (p->psig==NULL)
                  printf("Elemento no Encontardo");
                  else
                  {
                      if (cab=q)
                      cab=q->psig;
                      else
                      p->psig=q->psig;
                  }
                  
                  delete(q);
       }
                                    
     getch();
     system("CLS");
 }
                            
                            
        
                            
void eliminarnodofinal()
{
     p=cab;
     if (cab==NULL)
     printf("No hay Numeros en la lista");
    if (cab->psig==NULL)
    {
        delete (cab);
        cab=NULL;
        }
    
     else
     {
        
    while(p->psig!=NULL)
    {
    aux=p;
    p=p->psig;
}
    aux->psig=NULL;
    delete p;
    numerodenodos--;
}
 getch();
 system("cls");    
}






void eliminarnodoinicio()
{
    
     if (cab==NULL)
     printf("No hay numeros que eliminar");
     else
     {
      
         aux=cab;
         cab=cab->psig;
         delete (aux);
         aux=NULL;
         numerodenodos--;
}    
 getch();
 system("cls");    
}
 
 
            
void buscarnumero()
{
     int eli;
      if (cab==NULL)
      {
     printf("No hay numeros en la lista");
     }
     else
     {
     q=cab;
     printf("Que Numero desea buscar: ");
     scanf("%d",&x);
     pos=1;
     while(q!=NULL && q->numero!=x)
     {
     q=q->psig;
     pos++;
     }
    
     if (q!=NULL)
     printf("%d Esta en la lista y en la posicion %d\n",x,pos);
    
    
     else
     {
          printf("%d No esta en la lista\n",x);
          
          }    
}    

 getch();
 system("cls");    
    
 }
                  
 void insertarnodoinicio(){
 n=(dato*)malloc(sizeof (struct dato));
 printf("\nElementos a insertar: ");
 scanf("%d",&x);
 n->numero=x;
 n->psig=NULL;
 if(cab==NULL)
 cab=n;
                                                      
 else{
 n->psig=cab;
 cab=n;
 }
 numerodenodos++;
                                                      
 system("CLS");
                                                      
 }
            
 void mostrarnodo()
 {
 if(cab==NULL)
 printf("Lista vacia.........\n");
                                        
 else{
 p=cab;
 printf("\nLista de numeros...\n");
 while(p!=NULL){
 printf("\n%d\n",p->numero);
 p=p->psig;
 }
 printf("\nEl numero de nodos es: %d ",numerodenodos);
                                                    
                                                      
 }
 getch();
 system("CLS");
 }
                                        
 void insertarnodoalfinal()
 {
 n= (dato*)malloc(sizeof(dato));
 printf("Ingresa dato:  ");
 scanf("%d",&x);
 n->numero=x;
 n->psig=NULL;
 if(cab==NULL){
 cab=n;
 numerodenodos++;
 }
 else{
 p=cab;
 while(p->psig!=NULL)
 {
 p=p->psig;
 }
 p->psig=n;
 numerodenodos++;
 }
 getch();
 system("CLS");
                                            
 }
                                  
   void insertarentrenodos()
 {
      if(cab==NULL)
      printf("No hay  elementos");
      else
      {
          
          
             printf("Ingrese la posicion en que desees insertar: ");
             scanf("%d",&pos);
            
             if(pos> numerodenodos || pos==1)
             printf("Solamente es valido entre 2 nodos");
             else
             {
                 n=(dato*)malloc(sizeof(dato));
                 printf("Ingresa dato: ");
                 scanf("%d",&x);
                 n->numero=x;
                 n->psig=NULL;
                              aux=cab;
                 for(int i=1; i<pos-1; i++)
                
             {
                 aux=aux->psig;
                 }
                 n->psig=aux->psig;
                 aux->psig=n;
                  numerodenodos++;
                 }
                 }
                 getch();
                 system("cls");
 }


tengo este programa pero tengo un error cuando intento compilar con gcc me marca lo siguiente alguien ayuda
ListasSimples.c:16:3: error: unknown type name ‘dato’
   dato *psig;
   ^
ListasSimples.c:20:7: error: unknown type name ‘dato’
       dato *cab=NULL;
       ^
ListasSimples.c:21:7: error: unknown type name ‘dato’
       dato *n=NULL;
       ^
ListasSimples.c:22:7: error: unknown type name ‘dato’
       dato *aux=NULL;
       ^
ListasSimples.c:23:7: error: unknown type name ‘dato’
       dato *p=NULL;
       ^
ListasSimples.c:24:7: error: unknown type name ‘dato’
       dato *q;
       ^
ListasSimples.c:27:7: warning: return type defaults to ‘int’ [-Wimplicit-int]
       main()
       ^
ListasSimples.c: In function ‘main’:
ListasSimples.c:84:37: warning: implicit declaration of function ‘getch’ [-Wimplicit-function-declaration]
                                     getch();
                                     ^
ListasSimples.c: In function ‘eliminarentredosnodos’:
ListasSimples.c:104:22: error: request for member ‘numero’ in something not a structure or union
              while (q->numero!=x && h==1)
                      ^
ListasSimples.c:106:19: error: request for member ‘psig’ in something not a structure or union
              if (q->psig!=NULL)
                   ^
ListasSimples.c:109:35: error: request for member ‘psig’ in something not a structure or union
                                q=q->psig;
                                   ^
ListasSimples.c:115:24: error: request for member ‘psig’ in something not a structure or union
                   if (p->psig==NULL)
                        ^
ListasSimples.c:120:28: error: request for member ‘psig’ in something not a structure or union
                       cab=q->psig;
                            ^
ListasSimples.c:122:24: error: request for member ‘psig’ in something not a structure or union
                       p->psig=q->psig;
                        ^
ListasSimples.c:122:32: error: request for member ‘psig’ in something not a structure or union
                       p->psig=q->psig;
                                ^
ListasSimples.c:125:19: warning: implicit declaration of function ‘delete’ [-Wimplicit-function-declaration]
                   delete(q);
                   ^
ListasSimples.c: In function ‘eliminarnodofinal’:
ListasSimples.c:140:12: error: request for member ‘psig’ in something not a structure or union
     if (cab->psig==NULL)
            ^
ListasSimples.c:149:12: error: request for member ‘psig’ in something not a structure or union
     while(p->psig!=NULL)
            ^
ListasSimples.c:152:8: error: request for member ‘psig’ in something not a structure or union
     p=p->psig;
        ^
ListasSimples.c:154:8: error: request for member ‘psig’ in something not a structure or union
     aux->psig=NULL;
        ^
ListasSimples.c:155:5: error: unknown type name ‘delete’
     delete p;
     ^
ListasSimples.c: In function ‘eliminarnodoinicio’:
ListasSimples.c:176:17: error: request for member ‘psig’ in something not a structure or union
          cab=cab->psig;
                 ^
ListasSimples.c: In function ‘buscarnumero’:
ListasSimples.c:200:24: error: request for member ‘numero’ in something not a structure or union
      while(q!=NULL && q->numero!=x)
                        ^
ListasSimples.c:202:9: error: request for member ‘psig’ in something not a structure or union
      q=q->psig;
         ^
ListasSimples.c: In function ‘insertarnodoinicio’:
ListasSimples.c:223:5: error: ‘dato’ undeclared (first use in this function)
  n=(dato*)malloc(sizeof (struct dato));
     ^
ListasSimples.c:223:5: note: each undeclared identifier is reported only once for each function it appears in
ListasSimples.c:223:10: error: expected expression before ‘)’ token
  n=(dato*)malloc(sizeof (struct dato));
          ^
ListasSimples.c:226:3: error: request for member ‘numero’ in something not a structure or union
  n->numero=x;
   ^
ListasSimples.c:227:3: error: request for member ‘psig’ in something not a structure or union
  n->psig=NULL;
   ^
ListasSimples.c:232:3: error: request for member ‘psig’ in something not a structure or union
  n->psig=cab;
   ^
ListasSimples.c: In function ‘mostrarnodo’:
ListasSimples.c:250:19: error: request for member ‘numero’ in something not a structure or union
  printf("\n%d\n",p->numero);
                   ^
ListasSimples.c:251:5: error: request for member ‘psig’ in something not a structure or union
  p=p->psig;
     ^
ListasSimples.c: In function ‘insertarnodoalfinal’:
ListasSimples.c:263:6: error: ‘dato’ undeclared (first use in this function)
  n= (dato*)malloc(sizeof(dato));
      ^
ListasSimples.c:263:11: error: expected expression before ‘)’ token
  n= (dato*)malloc(sizeof(dato));
           ^
ListasSimples.c:266:3: error: request for member ‘numero’ in something not a structure or union
  n->numero=x;
   ^
ListasSimples.c:267:3: error: request for member ‘psig’ in something not a structure or union
  n->psig=NULL;
   ^
ListasSimples.c:274:9: error: request for member ‘psig’ in something not a structure or union
  while(p->psig!=NULL)
         ^
ListasSimples.c:276:5: error: request for member ‘psig’ in something not a structure or union
  p=p->psig;
     ^
ListasSimples.c:278:3: error: request for member ‘psig’ in something not a structure or union
  p->psig=n;
   ^
ListasSimples.c: In function ‘insertarentrenodos’:
ListasSimples.c:301:21: error: ‘dato’ undeclared (first use in this function)
                  n=(dato*)malloc(sizeof(dato));
                     ^
ListasSimples.c:301:26: error: expected expression before ‘)’ token
                  n=(dato*)malloc(sizeof(dato));
                          ^
ListasSimples.c:304:19: error: request for member ‘numero’ in something not a structure or union
                  n->numero=x;
                   ^
ListasSimples.c:305:19: error: request for member ‘psig’ in something not a structure or union
                  n->psig=NULL;
                   ^
ListasSimples.c:310:25: error: request for member ‘psig’ in something not a structure or union
                  aux=aux->psig;
                         ^
ListasSimples.c:312:19: error: request for member ‘psig’ in something not a structure or union
                  n->psig=aux->psig;
                   ^
ListasSimples.c:312:29: error: request for member ‘psig’ in something not a structure or union
                  n->psig=aux->psig;
                             ^
ListasSimples.c:313:21: error: request for member ‘psig’ in something not a structure or union
                  aux->psig=n;
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines