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

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


  Mostrar Temas
Páginas: [1]
1  Programación / Programación Visual Basic / Calculadora simple [VB] en: 14 Octubre 2010, 05:01 am
Hola migos, hace dos dias comence con esto de visual basic la verdad me parece un lenguaje muy bueno para aplicaciones graficas, estoy usando visual studio k es realmente completo y facil de usar, empeze a hacer una simple calculadora, bueno aki esta el codigo del algoritmo de calculos no el de los graficos..bueno amigos espero cualkier comentario que me ayude a aprender mas..saludos ::)

link del .exe: http://www.megaupload.com/?d=G5WU7VAJ


Código
  1. Public Class Ventana
  2.    Dim Valor1 As Double, Result As Double, Valor2 As Double, Marca_Suma As Boolean
  3.    Dim Marca_Resta As Boolean, Marca_Multiplicacion As Boolean, Marca_Division As Boolean
  4.  
  5.    Private Sub Uno_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Uno.Click
  6.        Valor1 = Valor1 * 10 + 1
  7.        Pantalla.Text = Valor1
  8.    End Sub
  9.  
  10.    Private Sub Dos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dos.Click
  11.        Valor1 = Valor1 * 10 + 2
  12.        Pantalla.Text = Valor1
  13.    End Sub
  14.  
  15.    Private Sub Tres_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tres.Click
  16.        Valor1 = Valor1 * 10 + 3
  17.        Pantalla.Text = Valor1
  18.    End Sub
  19.  
  20.    Private Sub Cuatro_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cuatro.Click
  21.        Valor1 = Valor1 * 10 + 4
  22.        Pantalla.Text = Valor1
  23.    End Sub
  24.  
  25.    Private Sub Cinco_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cinco.Click
  26.        Valor1 = Valor1 * 10 + 5
  27.        Pantalla.Text = Valor1
  28.    End Sub
  29.  
  30.    Private Sub Seis_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Seis.Click
  31.        Valor1 = Valor1 * 10 + 6
  32.        Pantalla.Text = Valor1
  33.    End Sub
  34.  
  35.    Private Sub Siete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Siete.Click
  36.        Valor1 = Valor1 * 10 + 7
  37.        Pantalla.Text = Valor1
  38.    End Sub
  39.  
  40.    Private Sub Ocho_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ocho.Click
  41.        Valor1 = Valor1 * 10 + 8
  42.        Pantalla.Text = Valor1
  43.    End Sub
  44.  
  45.    Private Sub Nueve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nueve.Click
  46.        Valor1 = Valor1 * 10 + 9
  47.        Pantalla.Text = Valor1
  48.    End Sub
  49.  
  50.    Private Sub Cero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cero.Click
  51.        Valor1 = Valor1 * 10
  52.        Pantalla.Text = Valor1
  53.    End Sub
  54.  
  55.    Private Sub Resta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Resta.Click
  56.        Pantalla.Text = "-"
  57.        Valor2 = Valor1
  58.        Valor1 = 0
  59.        Marca_Resta = True
  60.    End Sub
  61.  
  62.    Private Sub Suma_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Suma.Click
  63.        Pantalla.Text = "+"
  64.        Valor2 = Valor1
  65.        Valor1 = 0
  66.        Marca_Suma = True
  67.    End Sub
  68.  
  69.    Private Sub Dividir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dividir.Click
  70.        Pantalla.Text = "/"
  71.        Valor2 = Valor1
  72.        Valor1 = 0
  73.        Marca_Division = True
  74.    End Sub
  75.  
  76.    Private Sub Multiplicar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Multiplicar.Click
  77.        Pantalla.Text = "x"
  78.        Valor2 = Valor1
  79.        Valor1 = 0
  80.        Marca_Multiplicacion = True
  81.    End Sub
  82.  
  83.    Private Sub Resultado_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Resultado.Click
  84.        If Marca_Suma = True Then
  85.            Result = Valor2 + Valor1
  86.        ElseIf Marca_Resta = True Then
  87.            Result = Valor2 - Valor1
  88.        ElseIf Marca_Multiplicacion = True Then
  89.            Result = Valor2 * Valor1
  90.        ElseIf Marca_Division = True Then
  91.            Result = Valor2 / Valor1
  92.        End If
  93.        Pantalla.Text = Result
  94.    End Sub
  95.  
  96.    Private Sub Limpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Limpiar.Click
  97.        Pantalla.Text = "" : Valor1 = 0 : Valor2 = 0
  98.        Marca_Division = False : Marca_Multiplicacion = False : Marca_Resta = False : Marca_Suma = False
  99.    End Sub
  100. End Class
  101.  
2  Programación / Scripting / Codigos simples para compartir [Python] en: 9 Octubre 2010, 08:33 am
Hola, estoy aprendiendo Python, el cual me ha sorprendido bastante, bueno comparto con ustedes estos simples programas que me han ayudado a aprender este lenguaje tan potente, saludos. ::)

Código
  1. # Autor: GLAS
  2. # dado un valor numerico desde teclado
  3. # imprimir si es primo o no.
  4. # NOTA: un numero primo es aquel que es divisible
  5. # por 1 y por si mismo. El 0 y 1 no son primos.
  6.  
  7. import os
  8. while True:
  9. os.system("clear")
  10. print "Ingrese un numero: "
  11. valor1=raw_input("> ")
  12. if valor1== "exit": # se escribe exit para salir.
  13. break
  14. valor1=int(valor1) # cadena a valor.
  15. if valor1==0 or valor1==1: # 0 y 1 no son primos.
  16. print "numeros 0 y 1 no se consideran primos."
  17. raw_input()
  18. if valor1==2:
  19. print "el numero " + str(valor1) + " es primo."
  20. raw_input()
  21. if valor1>2:
  22. divisor=valor1
  23. marca=0
  24. while divisor >=2:
  25. if valor1%divisor==0:
  26. marca=marca+1
  27. divisor=divisor-1 # divisor decreciente desde el valor1.
  28. if marca==1: # indica que el numero es divisible por 1 y si mismo.
  29. print "el numero " + str(valor1) + " es primo."
  30. raw_input()
  31. if marca>=2: # indica que el numero es divisible por otro numero.
  32. print "el numero " + str(valor1) + " no es primo."
  33. raw_input()
  34. os.system("clear")
  35.  
3  Programación / Programación C/C++ / Programa codificador de texto a base64 estandar. [C/C++] en: 3 Octubre 2010, 02:11 am
Hola amigos, estudiando un tema de protocolos de internet me encontre con la codificación en base64, la verdad no la conocia, por tanto me puse a estudiar su funcionamiento y que mejor forma de aprenderla que haciendo un programa en C, el cual codifica un texto ingresado en la consola en donde devuelve su resultado en base64 en la misma consola, el programa lo hice bajo Linux Ubuntu, bueno aqui lo dejo espero les ayude en algo, dejen su comentario y/o consejo, trate de utilizar lo menos posibe de funciones ya existentes, bueno saludos. ::)

NOTA: (algunas funciones como; printf() y puts() eran para analisis y depuracion del programa las deje como comentarios), dejen comentario de como reducir el codigo por favor.

Código
  1. //Autor: Jonathan Carrasco (GLAS)
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. main()
  5. {
  6. //int tarea;
  7. void Codificar();
  8. //void Decodificar();
  9. system("clear");
  10. printf("**************************\n");
  11. printf("******** Code 64 *********\n");
  12. printf("**************************\n");
  13. //printf(" Seleccione una tarea....\n\n");
  14. //printf(" 1)Codificar base 64.\n 2)Decodificar base 64.\n");
  15. //scanf("%d",&tarea); getchar();
  16. //if(tarea==1) { Codificar(); }
  17. //if(tarea==2) { Decodificar(); }
  18. Codificar();
  19. getchar();
  20. system("clear");
  21. return 0;
  22. }
  23. //-------------------------------------------------------
  24. void Codificar()
  25. {
  26. int i,n,c=1,r=0,p=7,s=0;
  27. char texto[10000],bin[80],cambio[6],store[15000],envio[6],a;
  28. void b_decimal(char valor_b[6]);
  29. printf("Ingrese texto a Codificar: ");
  30. gets(texto); printf("\n\n");
  31. for(i=0;texto[i]!='\0';i++)
  32. {
  33. n=texto[i];
  34. //printf(" %d ",n);
  35. while(n>=1)
  36. {
  37.   r=n%2;
  38.   n=n/2;
  39.   if(r==1) { bin[p]='1'; p--; }//store[s]='1'; s++; }
  40.   if(r==0) { bin[p]='0'; p--; }//store[s]='0'; s++; }
  41. }
  42. bin[p]='0'; p--; bin[8]='\0'; p=0;
  43. while(bin[p]!='\0')
  44. {
  45. store[s]=bin[p]; s++; p++;
  46. }
  47. //puts(bin);
  48. p=7;
  49. }
  50. store[s]='\0'; //puts(store); printf(" %d bits\n",s);
  51. s=0;
  52. while(store[s]!='\0')
  53. {
  54. for(p=0;p<=5;s++,p++) { envio[p]=store[s]; }
  55. envio[6]='\0'; //puts(envio);
  56. b_decimal(envio);
  57. }
  58. }
  59. //-------------------------------------------------------
  60. void b_decimal(char valor_b[6]) //funcion conversion binario-decimal
  61. {
  62. int c,n,v=0,r=0,m=0; //forma de conversion: 11001 -> 1*(2e4) + 1*(2e3) + 0*(2e2) + 0*(2e1) + 1*(2e0) = 16 + 8 + 0 + 0 + 1 = 25
  63. while(valor_b[m]!='\0') { m++; }
  64. if(m==2) { valor_b[2]='0'; valor_b[3]='0'; valor_b[4]='0'; valor_b[5]='0'; valor_b[6]='\0'; }
  65. if(m==4) { valor_b[4]='0'; valor_b[5]='0'; valor_b[6]='\0'; }
  66. //puts(valor_b);
  67. for(c=5;c>=0;)
  68. {
  69.  n=(valor_b[c]-'0');
  70.  v=v*2;
  71.  if(v==0) v=1;
  72.  n=n*v; c--;
  73.  r=r+n;
  74. }
  75. //printf("%d  ",r);
  76.  
  77. if(r==0) { printf("A"); }
  78. if(r==1) { printf("B"); }
  79. if(r==2) { printf("C"); }
  80. if(r==3) { printf("D"); }
  81. if(r==4) { printf("E"); }
  82. if(r==5) { printf("F"); }
  83. if(r==6) { printf("G"); }
  84. if(r==7) { printf("H"); }
  85. if(r==8) { printf("I"); }
  86. if(r==9) { printf("J"); }
  87. if(r==10) { printf("K"); }
  88. if(r==11) { printf("L"); }
  89. if(r==12) { printf("M"); }
  90. if(r==13) { printf("N"); }
  91. if(r==14) { printf("O"); }
  92. if(r==15) { printf("P"); }
  93. if(r==16) { printf("Q"); }
  94. if(r==17) { printf("R"); }
  95. if(r==18) { printf("S"); }
  96. if(r==19) { printf("T"); }
  97. if(r==20) { printf("U"); }
  98. if(r==21) { printf("V"); }
  99. if(r==22) { printf("W"); }
  100. if(r==23) { printf("X"); }
  101. if(r==24) { printf("Y"); }
  102. if(r==25) { printf("Z"); }
  103.  
  104. if(r==26) { printf("a"); }
  105. if(r==27) { printf("b"); }
  106. if(r==28) { printf("c"); }
  107. if(r==29) { printf("d"); }
  108. if(r==30) { printf("e"); }
  109. if(r==31) { printf("f"); }
  110. if(r==32) { printf("g"); }
  111. if(r==33) { printf("h"); }
  112. if(r==34) { printf("i"); }
  113. if(r==35) { printf("j"); }
  114. if(r==36) { printf("k"); }
  115. if(r==37) { printf("l"); }
  116. if(r==38) { printf("m"); }
  117. if(r==39) { printf("n"); }
  118. if(r==40) { printf("o"); }
  119. if(r==41) { printf("p"); }
  120. if(r==42) { printf("q"); }
  121. if(r==43) { printf("r"); }
  122. if(r==44) { printf("s"); }
  123. if(r==45) { printf("t"); }
  124. if(r==46) { printf("u"); }
  125. if(r==47) { printf("v"); }
  126. if(r==48) { printf("w"); }
  127. if(r==49) { printf("x"); }
  128. if(r==50) { printf("y"); }
  129. if(r==51) { printf("z"); }
  130.  
  131. if(r==52) { printf("0"); }
  132. if(r==53) { printf("1"); }
  133. if(r==54) { printf("2"); }
  134. if(r==55) { printf("3"); }
  135. if(r==56) { printf("4"); }
  136. if(r==57) { printf("5"); }
  137. if(r==58) { printf("6"); }
  138. if(r==59) { printf("7"); }
  139. if(r==60) { printf("8"); }
  140. if(r==61) { printf("9"); }
  141.  
  142. if(r==62) { printf("+"); }
  143. if(r==63) { printf("/"); }
  144. if(m==2) { printf("=="); }
  145. if(m==4) { printf("="); }
  146. //printf("\n");
  147. }
  148. //funcionamiento todo OK.
  149.  
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines