User Tools

Site Tools


fidonet:clang.ita

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

fidonet:clang.ita [30/12/2024 06:13] – created lrosafidonet:clang.ita [30/12/2024 14:27] (current) lrosa
Line 1: Line 1:
 +====== CLANG.ITA ======
 +===== Descrizione =====
 +Area italiana dedicata al linguaggio C.
 +===== Messaggi interi =====
 +==== Re: Struttura messaggi OPUS ====
 +<code>
 +        09 Nov 89 15:54:00
 +From:   Flavio Bernardotti
 +To:     Luigi Rosa
 +Subj:   Re: Struttura messaggi OPUS
 +------------------------------------------------
 +Ah sì? Ma Opus Pavia è in rete? Se sì, è quello di Martinelli?  
 +
 +Ciao 
 +
 +--- ITALMAIL v2.06
 + * Origin: ITALINK CBBS Montecastello (0131-355506)   (2:334/2)
 +</code>
 +==== FORMULA PER CALCOLO N.SETTIMANE ====
 +<code>
 +=============================================================================
 +* Area : CLANG.ITA (Linguaggio C)
 +* From : Salvatore Manzi, 2:332/108.7 (02 Apr 91 20:01)
 +* To   : Duncan Wilcox
 +* Subj : Congruenza di Zeller
 +=============================================================================
 +
 +//                           by Jeff Duntemann
 +//---------------------------------------------------------
 +// calc_day_of_week calculates the day of the week using
 +//   Zeller's Congruence, and returns a value from 0-6,
 +//   where 0 = Sunday, 1 = Monday, and so on.
 +//
 +
 +int calc_day_of_week(int year,
 +             int month,
 +             int day)
 +
 +{
 +  int century, holder;
 +
 +  // First test for error conditions on input values:
 +  if ((year < 0)  ||                   // Test for bad year
 +      (month < 1) || (month > 12) ||   // Test for bad month
 +      (day < 1)   || (day > 31))       // Test for bad day
 +     return -1;             // Return -1 to indicate an error
 +  else
 +    /* Do the Zeller's Congruence calculation as Zeller himself */
 +    /* described it in "Acta Mathematica" #7, Stockhold, 1887.  */
 +    {
 +      // First we separate out the year and the century figures:
 +      century = year / 100;  // I.e., 19
 +      year    = year % 100;  // I.e., 90
 +
 +      // Next we adjust the month such that March remains month #3,
 +      //  but that January and February are months #13 and #14,
 +      //  *but of the previous year*.  This is done to put the
 +      //  weirdness of February at the *end* of the "year":
 +
 +      if (month < 3)   // Do this only for January & February!
 +    {
 +      month += 12;         // Increment month by 12
 +      if (year > 0)        // The year before 2000 is
 +        year -= 1;         //  1999, not 20-1, so
 +      else                 //  so if the year is 00,
 +        {                  //  we decrement the century
 +          year = 99;       //  and make the year 99.
 +          century -= 1;
 +        };
 +        };
 +
 +      // Here's Zeller's seminal black magic:
 +      holder = day;                        // Start with the day of month
 +
 +      // This is a magic pill that figures the number of days that occur
 +      //  prior to the start of the current month from *MARCH 1*:
 +      holder = holder + (((month+1) * 26) / 10);
 +
 +      holder = holder + year;              // Add in the year
 +      holder = holder + (year / 4);        // Correct for leap years
 +      holder = holder + (century / 4);     // Correct for century years
 +      holder = holder - century - century; // DON'T KNOW WHY HE DID THIS!
 +
 +      // modulus non fa altro che calcolare il modulo, non e' di libreria e per
 +      // l'ho tolta
 +      holder = modulus(holder,7);          // Take holder modulus 7
 +
 +      // Here we "wrap" Saturday around to be the last day:
 +      if (holder == 0)
 +    holder = 7;
 +
 +      // Zeller kept the Sunday = 1 origin; computer weenies prefer to
 +      // start everything with 0, so here's a 20th Century kludge:
 +      holder--;
 +
 +      return holder;  /* Return the end product! */
 +    };
 +};
 +
 +Nel tuo Main bastera' chiamare :calc_day_of_week(year,month,day);
 +</code>