Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.39 KB | None | 0 0
  1. /**
  2.  * \file easter.c
  3.  *
  4.  */
  5.  
  6. #include <stdio.h>
  7. /**
  8.  * \brief: oster-kontrolle
  9.  * guck fuer alle Jahre im eingabe-file an welchem Datum in dem jahr
  10.  * ostern war und gibt sie isn ausgabefile aus
  11.  * die steps 1-8 sind auf uebungsblatt 2 aufgabe 1 aufgefuert
  12.  * \return 0
  13.  */
  14. int main (int year, char **out)
  15. {
  16.    
  17.   int golden; /* das goldene Jahr*/
  18.   int century;/* jahrundert*/
  19.   int epact; /*vollmond-angabe*/
  20.   int schalt; /* ausgelassene schaltjahre*/
  21.   int moonorbit; /*faktor für die korrekru der Monumlaufbahn*/
  22.   int sonntag; /* faktor zum bestimmen des sonntages*/
  23.   int datum; /* das endgültige datum */
  24.  
  25.  
  26.  
  27.   while(  scanf("%i",&year) == 1){
  28.  
  29.  
  30.   golden = year % 19 +1;    /* step1 */
  31.    
  32.   century = year / 100 +1;    /* step2 */
  33.    
  34.   schalt = (3 * century / 4) -12;    /* step3 */
  35.   moonorbit = ((8 * century + 5) / 25) - 5;
  36.  
  37.   sonntag = (5*year / 4 ) - schalt - 10;  /* step4 */
  38.  
  39.   epact = (11 * golden + 20 + moonorbit - schalt) % 30;  /* step5 */
  40.   if( (epact == 25 && golden > 11) || epact == 24){
  41.     epact++;
  42.   }
  43.  
  44.   datum = 44 - epact;  /* step6 */
  45.   if(datum < 21) datum+= 30;
  46.  
  47.   datum = datum + 7 - ((sonntag + datum) % 7);    /* step 7 */
  48.  
  49.   /* step8 */
  50.   if( datum > 31) {
  51.     datum = datum -31;
  52.     printf("%d - April %d \n",year, datum);
  53.   }
  54.     else{
  55.       printf("%d - March %d \n",year, datum);
  56.     };
  57.  
  58.   }
  59.  
  60.     return 0;
  61.    
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement