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

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


  Mostrar Mensajes
Páginas: 1 [2] 3 4
11  Programación / Programación C/C++ / Programas para calcular fechas en: 12 Mayo 2017, 20:50 pm
Estimados,

Serian tan amables de indicarme que error tengo en estos dos programas:

1 - "Calcular fecha siguiente" (Me devuelve la misma fecha siempre)

Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct
  5. {
  6.    int dia,
  7.        mes,
  8.        año;
  9. }   tFecha;
  10.  
  11. void calcularFechaSiguiente (tFecha fecha);
  12.  
  13. int main()
  14. {
  15.    system ("color 0a");
  16.    tFecha fecha;
  17.    printf("Ingrese dia: \n\n");
  18.    scanf("%d",&fecha.dia);
  19.    printf("\nIngrese mes: \n\n");
  20.    scanf("%d",&fecha.mes);
  21.    printf("\nIngrese año: \n\n");
  22.    scanf("%d",&fecha.año);
  23.    calcularFechaSiguiente (fecha);
  24.    printf("\nFecha final: %d/%d/%d",fecha.dia,fecha.mes,fecha.año);
  25.    return 0;
  26. }
  27.  
  28. void calcularFechaSiguiente (tFecha fecha)
  29. {
  30.    if(fecha.mes == 4 || fecha.mes == 6 || fecha.mes == 9 || fecha.mes == 11)
  31.    {
  32.        if(fecha.dia == 30)
  33.        {
  34.            fecha.dia = 1;
  35.            fecha.mes++;
  36.        }
  37.        else
  38.            fecha.dia++;
  39.    }
  40.    if(fecha.mes == 2)
  41.    {
  42.        if ((fecha.año % 4 == 0) && ((fecha.año % 100 != 0) || (fecha.año % 400 == 0)))
  43.        {
  44.            if(fecha.dia == 29)
  45.            {
  46.                fecha.dia = 1;
  47.                fecha.mes++;
  48.            }
  49.            else
  50.                fecha.dia++;
  51.        }
  52.        if(fecha.dia == 28)
  53.        {
  54.            fecha.dia = 1;
  55.            fecha.mes++;
  56.        }
  57.        else
  58.            fecha.dia++;
  59.    }
  60.    if(fecha.mes == 1 || fecha.mes == 3 || fecha.mes == 5 || fecha.mes == 7 || fecha.mes == 8 || fecha.mes == 10)
  61.    {
  62.        if(fecha.dia == 31)
  63.        {
  64.            fecha.dia = 1;
  65.            fecha.mes++;
  66.        }
  67.        else
  68.            fecha.dia++;
  69.    }
  70.    if(fecha.dia == 31)
  71.    {
  72.        fecha.dia = 1;
  73.        fecha.mes = 1;
  74.        fecha.año++;
  75.    }
  76.    else
  77.        fecha.dia++;
  78. }

1 - "Calcular dias entres dos fechas" (Me devuelve un resultado cualquiera)

Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct
  5. {
  6.    int dia,
  7.        mes,
  8.        año;
  9. }   tFecha;
  10.  
  11. long calcularFecha (tFecha fecha1, tFecha fecha2);
  12.  
  13. int main()
  14. {
  15.    system ("color 0a");
  16.    tFecha fecha1,
  17.           fecha2;
  18.    long num;
  19.    printf("Ingrese dia - Primera fecha: \n\n");
  20.    scanf("%d",&fecha1.dia);
  21.    printf("\nIngrese mes - Primera fecha: \n\n");
  22.    scanf("%d",&fecha1.mes);
  23.    printf("\nIngrese año - Primera fecha: \n\n");
  24.    scanf("%d",&fecha1.año);
  25.    printf("\nIngrese dia - Segunda fecha: \n\n");
  26.    scanf("%d",&fecha2.dia);
  27.    printf("\nIngrese mes - Segunda fecha: \n\n");
  28.    scanf("%d",&fecha2.mes);
  29.    printf("\nIngrese año - Segunda fecha: \n\n");
  30.    scanf("%d",&fecha2.año);
  31.    num = calcularFecha (fecha1, fecha2);
  32.    printf("\nDias entre las dos fechas: %d.\n",num);
  33.    return 0;
  34. }
  35.  
  36. long calcularFecha (tFecha fecha1, tFecha fecha2)
  37. {
  38. long num = 0,
  39.        i;
  40. if(fecha1.año < fecha2.año)
  41.        for(i=fecha1.año;i<fecha2.año;i++)
  42.        {
  43.            if ((i % 4 == 0) && ((i % 100 != 0) || (i % 400 == 0)))
  44.                num += i*366;
  45.            else
  46.                num += i*365;
  47.        }
  48.    else
  49.        for(i=fecha2.año;i<fecha1.año;i++)
  50.        {
  51.            if ((i % 4 == 0) && ((i % 100 != 0) || (i % 400 == 0)))
  52.                num += i*366;
  53.            else
  54.                num += i*365;
  55.        }
  56.    if(fecha1.mes < fecha2.mes)
  57.        for(i=fecha1.mes;i<fecha2.mes;i++)
  58.        {
  59.            if(i == 4 || i == 6 || i == 9 || i == 11)
  60.                num += i*30;
  61.            if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
  62.                num += i*31;
  63.            if(i == 2)
  64.                num += i*28;
  65.        }
  66.    else
  67.        for(i=fecha2.mes;i<fecha1.mes;i++)
  68.        {
  69.            if(i == 4 || i == 6 || i == 9 || i == 11)
  70.                num += i*30;
  71.            if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
  72.                num += i*31;
  73.            if(i == 2)
  74.                num += i*28;
  75.        }
  76. if(fecha1.dia > fecha2.dia)
  77.        num += fecha1.dia - fecha2.dia;
  78. else
  79. num += fecha2.dia - fecha1.dia;
  80.    return num;
  81. }
  82.  

Desde ya muchas gracias.
Saludos!
12  Programación / Java / Compilador Java en: 2 Enero 2017, 21:21 pm
Estimados,

¿Serian tan amables de indicarme que debo descargar para programar con NetBeans en Java?

Tengan en cuenta que tengo dos opciones para alojar todo:

Windows XP 32 bits
Windows 7 32 bits


Estuve buscando en la pagina de Oracle pero ningún versión, ya sea JVE o JDK, se adapta a mis disponibilidad. Solo pude descargar el NetBeans pero sin compilador.

Si existe algún otro compilador que puedan recomendarme, también es bienvenido.

Muchas gracias!
13  Foros Generales / Dudas Generales / Re: Empresas de sistemas en: 7 Noviembre 2016, 17:46 pm
Hola!

De todo un poco.

Gracias!
14  Programación / Programación C/C++ / Re: Ayuda para sacar coseno en C. en: 7 Noviembre 2016, 17:43 pm
Muchas gracias!
15  Programación / Programación C/C++ / Ayuda para sacar coseno en C. en: 3 Noviembre 2016, 19:10 pm
Hola a todos,

La idea del ejercicio es que resuelva el coseno de un angulo.
Probe con el angulo de 180, cuyo resultado tendría que ser -1, pero este programa me duvuelve un 0.

Gracias!

Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7.    system ("color 0a");
  8.    float ang, fin;
  9.    printf("Ingrese: \n");
  10.    scanf("%d",&ang);
  11.    fin = cos(ang);
  12.    printf("final %d",fin);
  13.    return 0;
  14. }
16  Foros Generales / Dudas Generales / Empresas de sistemas en: 31 Octubre 2016, 15:38 pm
Hola a todos, buenos días,

Serian tan amables de nombrarme empresas de sistemas o informática, en donde se pueda pedir trabajo. Les comento que soy de Argentina.

Si también conocen, lugares, tanto físicos como en Internet, en donde se informe sobre eventos, seminarios, becas y congresos relacionados a la informática.

Y por ultimo, escuelas o institutos en donde dicten cursos de informática.

Muchas gracias!

17  Programación / Programación C/C++ / Re: Problema en suma de matrices en: 18 Octubre 2016, 22:19 pm
Ya funciono. Era como vos decías.

Muchisimas gracias!!
18  Programación / Programación C/C++ / Re: Problema en suma de matrices en: 18 Octubre 2016, 21:46 pm
Hola,

Si uso los DEFINE FIL 1 y COL 1, ya pacta que que los for's vayan de 0 a 1 (es decid, dos elementos)

¿O me estoy equivocando?

Gracias!
19  Programación / Programación C/C++ / Problema en suma de matrices en: 18 Octubre 2016, 21:29 pm
Hola, buenas tardes,

El siguiente programa intenta sumar dos matrices de 2x2.
El problema se da que devuelve cualquier resultado, menos la suma.

Gracias!


Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define COL 1
  4. #define FIL 1
  5.  
  6. void ingresarMatriz (int[][COL]);
  7. void sumarMatriz (int[][COL], int[][COL], int[][COL]);
  8. void mostrarMatriz (int[][COL]);
  9.  
  10. int main()
  11. {
  12.    system ("color 0a");
  13.    int matrizA[FIL][COL],
  14.        matrizB[FIL][COL],
  15.        matrizC[FIL][COL];
  16.    printf("\t\tDATOS PRIMERA MATRIZ:\n");
  17.    ingresarMatriz(matrizA);
  18.    printf("\t\tDATOS SEGUNDA MATRIZ:\n");
  19.    ingresarMatriz(matrizB);
  20.    sumarMatriz(matrizA, matrizB, matrizC);
  21.    printf("\t\tMATRIZ FINAL:\n");
  22.    mostrarMatriz(matrizC);
  23.    return 0;
  24. }
  25.  
  26. void ingresarMatriz (int matriz[][COL])
  27. {
  28.    int i,
  29.        j;
  30.    for(i=0;i<=FIL;i++)
  31.    {
  32.        for(j=0;j<=COL;j++)
  33.        {
  34.            scanf("%d",&matriz[i][j]);
  35.        }
  36.    }
  37. }
  38.  
  39. void sumarMatriz (int matriz1[][COL], int matriz2[][COL], int matriz3[][COL])
  40. {
  41.    int i,
  42.        j;
  43.    for(i=0;i<=FIL;i++)
  44.    {
  45.        for(j=0;j<=COL;j++)
  46.        {
  47.            matriz3[i][j] = matriz1[i][j] + matriz2[i][j];
  48.        }
  49.    }
  50. }
  51.  
  52. void mostrarMatriz (int matriz3[][COL])
  53. {
  54.    int i,
  55.        j;
  56.    for(i=0;i<=FIL;i++)
  57.    {
  58.        for(j=0;j<=COL;j++)
  59.        {
  60.            printf("\n%d\n",matriz3[i][j]);
  61.        }
  62.    }
  63. }
  64.  
20  Programación / Programación C/C++ / Re: Problema y duda con incremento de punteros en: 6 Septiembre 2016, 20:34 pm
Barbaro,

Muchas gracias!
Páginas: 1 [2] 3 4
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines