daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 54 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 <iostream>
  4. #include <cmath>
  5. using namespace std;
  6.  
  7. int zeller(int , int, int);
  8.  
  9. int main()
  10. {
  11.     int meses[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  12.     string dia_sem;
  13.     int mes;
  14.     int dia;
  15.     int anio;
  16.     int res;
  17.     do
  18.     {
  19.         cout << "\nDia: ";
  20.         cin >> dia;
  21.         cout << "\nMes: ";
  22.         cin >> mes;
  23.         if (dia > meses[mes]) cout <<"\nError En El Mes Seleccionado No Existe Tal Dia\n";
  24.         if (dia < 1) cout << "\nError! Dia 0 no Existe!\n";
  25.         if (mes < 1 || mes > 12) cout <<"\nError. Rango De Mes: 1-12\n";
  26.     }while (dia > meses[mes] || dia < 1 || mes < 1 || mes > 12);
  27.  
  28.     cout << "\nA\244o: ";
  29.     cin >> anio;
  30.     if (mes < 3) anio = anio - 1;
  31.     res = zeller(anio, mes, dia);
  32.     switch (res)
  33.     {
  34.          case 0:
  35.                 dia_sem = "Domingo";
  36.                 break;
  37.          case 1:
  38.                 dia_sem = "Lunes";
  39.                 break;
  40.          case 2:
  41.                 dia_sem = "Martes";
  42.                 break;
  43.          case 3:
  44.                 dia_sem = "Miercoles";
  45.                 break;
  46.          case 4:
  47.                 dia_sem = "Jueves";
  48.                 break;
  49.          case 5:
  50.                 dia_sem = "Viernes";
  51.                 break;
  52.          case 6:
  53.                 dia_sem = "Sabado";
  54.                 break;
  55.     }
  56.    
  57.     cout << "\nLa Fecha Corresponde Con Un " << dia_sem << endl << endl;
  58.     system("pause");
  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