daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Programa: Congruencia De Zeller
  2.   Realizado Por: Jorge Chayan*/
  3. #include <stdio.h>
  4. #include <cmath>
  5.  
  6. int zeller(int , int, int);
  7.  
  8. int main()
  9. {
  10.     int meses[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  11.     char *dia_sem;
  12.     int mes;
  13.     int dia;
  14.     int anio;
  15.     int res;
  16.     do
  17.     {
  18.         printf ("\nDia: ");
  19.         scanf ("%d", &dia);
  20.         printf ("\nMes: ");
  21.         scanf ("%d", &mes);
  22.         if (dia > meses[mes]) printf ("\nError En El Mes Seleccionado No Existe Tal Dia\n");
  23.         if (dia < 1) printf ("\nError! Dia 0 no Existe!\n");
  24.         if (mes < 1 || mes > 12) printf ("\nError. Rango De Mes: 1-12\n");
  25.     }while (dia > meses[mes] || dia < 1 || mes < 1 || mes > 12);
  26.  
  27.     printf ("\nA\244o: ");
  28.     scanf ("%d", &anio);
  29.     if (mes < 3) anio = anio - 1;
  30.     res = zeller(anio, mes, dia);
  31.     switch (res)
  32.     {
  33.          case 0:
  34.                 dia_sem = "Domingo";
  35.                 break;
  36.          case 1:
  37.                 dia_sem = "Lunes";
  38.                 break;
  39.          case 2:
  40.                 dia_sem = "Martes";
  41.                 break;
  42.          case 3:
  43.                 dia_sem = "Miercoles";
  44.                 break;
  45.          case 4:
  46.                 dia_sem = "Jueves";
  47.                 break;
  48.          case 5:
  49.                 dia_sem = "Viernes";
  50.                 break;
  51.          case 6:
  52.                 dia_sem = "Sabado";
  53.                 break;
  54.     }
  55.    
  56.     printf ("\nLa Fecha Corresponde Con Un %s", dia_sem);
  57.     getchar();
  58.     getchar();
  59.     return 0;
  60. }
  61.  
  62. int zeller(int y, int m, int d)
  63. {
  64.     int c = y / 100; //centuria
  65.     float f = ((2.6*m - 0.2) + d + y + (y / 4) + (c / 4) - 2*c);
  66.     return (int) round(f) % 7;
  67. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top