Oggi vi propongo una versione modificata del codice postato ieri , ho eliminato qualche stringa di codice inutile per il calcolo che devo andare ad eseguire, ho modificato la formattazione dell'output ed infine ho inserito un ciclo che mi permette di calcolare la data di diversi anni che vanno da un anno x ad un anno y nel mio caso ho deciso di calcolare tutti i 916 anni che potevo calcolare con l'algoritmo precedente.
Ecco il codice:
- public class Pasqua916
- {
- {/ / algorithm for calculating the Christian Easter according to the Gregorian calendar (arithmetic method of Gauss) http://it.wikipedia.org/wiki/Calcolo_della_Pasqua # Metodo_aritmetico_di_Gauss
- int y = 1583; / / Gregorian year between 1583 and 2499
- while (y ! = 2500 )
- {
- to int y = 19% ;
- int b = y % 4 ;
- int c = y % 7 ;
- int m = 0 ;
- int n = 0 ;
- / / assignment m and n according to the century of y
- if ( y> = 1583 & & y \u0026lt;= 1699)
- {
- m = 22 ;
- n = 2 ;
- }
- else if ( y >= 1700 && y <= 1799 )
- {
- m = 23 ;
- n = 3 ;
- }
- else if ( y >= 1800 && y <= 1899 )
- {
- m = 23 ;
- n = 4 ;
- }
- else if ( y >= 1900 && y <= 2099 )
- {
- m = 24 ;
- n = 5 ;
- }
- else if ( y >= 2100 && y <= 2199 )
- {
- m = 24 ;
- n = 6 ;
- }
- else if ( y >= 2200 && y <= 2299 )
- {
- m = 25 ;
- n = 0 ;
- }
- else if ( y >= 2300 && y <= 2399 )
- {
- m = 26 ;
- n = 1 ;
- }
- else if ( y >= 2400 && y <= 2499 )
- {
- m = 25 ;
- n = 1 ;
- }
- / / compute d and e
- int d = ( 19 * a + m ) % 30 ;
- int e = ( 2 * b + 4 * c + 6 * d + n ) % 7 ;
- / / calculate the days
- if ( d + and \u0026lt; 10)
- {
- ; March int d = and + + 22; / / March case
- }
- else
- {
- int April = d + and - 9 ;
- if ( April == 26) / / exception April 1
- else if ( aprile == 25 && e == 6 && a > 10 ) //eccezione 2 aprile
- else / / generic case in April
- }
- y ++;
- }
- }
- }
You can find here all my programs .
0 comments:
Post a Comment