calcolo della data della pasqua

Stato
Discussione chiusa ad ulteriori risposte.

Oromis92

Utente Silver
22 Dicembre 2007
102
12
2
84
sbizzarritevi.
ci sono un casino di metodi diversi per calcolare la data della pasqua: epatta, numero d'oro, gauss...

io ho usato il metodo oudin-tondering
Codice:
#!/usr/bin/perl
use integer;

print "inserisci l'anno: ";
$anno = <>;
chomp $anno;
$a = $anno/100;
$b = $anno-19*($anno/19);
$c = ($a-17)/25;
$d = $a-$a/4-($a-$c)/3+19*$b+15;
$d = $d-30*($d/30);
$d = $d-($d/28)*(1-($d/28)*(29/($d+1))*((21-$b)/11));
$e = $anno+$anno/4+$d+2-$a+$a/4;
$e = $e-7*($e/7);
$z = $d-$e;

$mese = 3+($z+40)/44;
$giorno = $z+28-31*($mese/4);

print "nel $anno la pasqua cade il $giorno/$mese\n";
 
Con Gauss in C:
Codice:
#include<stdio.h>
#include<stdlib.h>

main()
{
      int a,b,c,d,e,m,n,giorno,mese,anno;
      printf("Inserisci l'anno\n");
      scanf("%d",&anno);
      if(anno>1582 && anno<1700){
          m=22;
          n=2;
      }
      else if(anno>1699 && anno<1800)
      {
           m=23;
           n=3;
      }
      else if(anno>1799 && anno<2000)
      {
           m=23;
           n=4;
      }
      else if(anno>1999 && anno<2100)
      {
           m=24;
           n=5;
      }
      else if(anno>2099 && anno<2200)
      {
           m=24;
           n=6;
      }
      else if(anno>2199 && anno<2300)
      {
           m=25;
           n=0;
      }
      else if(anno>2299 && anno<2400)
      {
           m=26;
           n=1;
      }
      else if(anno>2399 && anno<2500)
      {
           m=25;
           n=1;
      }
      a=anno%19;
      b=anno%4;
      c=anno%7;
      d=(19*a+m)%30;
      e=(2*b+4*c+6*d+n)%7;
      if(d+e<10){
          giorno=d+e+22;
          mese=3;
      } else {
          giorno=d+e-9;
          mese=4;
          if(giorno==26 || giorno==25 && d==28 && e==6 && a>10)
              giorno-=7;
      }
      printf("Nell'anno %d la pasqua cadra' il %d/%d\n",anno,giorno,mese);
      system("pause");
}
 
http://it.wikipedia.org/wiki/Programmi_di_calcolo_della_Pasqua
ci son tutti con Gauss
oromis quello è php?
 
ecco il mio in java con tanto di GUI:
JAVA - SWING
Codice:
/*
 * calcolatore.java
 *
 * Created on 29 gennaio 2009, 16.30
 */

import java.io.*;

/**
 *
 * @author  kripnos
 */
public class calcolatore extends javax.swing.JFrame {    
    public calcolatore() {
        initComponents();
    }
    
 
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Giorno di pasqua");

        jLabel1.setText("jLabel1");

        jButton1.setText("::  calcola   ::");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel2.setText("                 ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        String str = jTextField1.getText();
        int anno;
        anno = str.parseInt();
        double a = anno/100;
        double b = anno-19*(anno/19);
        double c = (a-17)/25;
        double d = a-a/4-(a-c)/3+19*b+15;
         d = d-30*(d/30);
         d = d-(d/28)*(1-(d/(14+14))*(29/(d+1))*((21-b)/11));
         double e = anno+anno/4+d+2-a+a/4;
          e = e-7*(e/7);
          double z = d-e;
          double mese = 3+(z+40)/44;
         double  giorno = z+28-31*(mese/4);
         jLabel2.setText("Pasqua avverra nel "+giorno+"/"+mese+"/"+anno);
    }
    
    
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new calcolatore().setVisible(true);
            }
        });
    }

    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField jTextField1; 
    
}
[ot]
scusa oromis se ho usato il tuo metodo[/ot]
 
[ot]oudin non lo conosco, ma tondering è vivo e vegeto e detiene le calendar faq (tante fuck sui calendari, veramente interessanti): http://tondering.dk/claus/calendar.html[/ot]
 
Oromis92 ha detto:
[ot]oudin non lo conosco, ma tondering è vivo e vegeto e detiene le calendar faq (tante fuck sui calendari, veramente interessanti): http://tondering.dk/claus/calendar.html[/ot]
odio i calendari XD
 
[C++]
Codice:
#include <iostream>
using namespace std;
int main() {
  int year, a, b, c, d, e, m, n;
  cout<<"Inserisci l'anno: ";
  cin>>year;
  a=year%19;
  b=year%4;
  c=year%7;
  if (year>=1583 and year<=1699) {
     m=22;
       n=2;
  }
  else if (year>=1700 and year<=1799){
       m=23;
       n=3;
  }
  else if (year>=1800 and year<=1899) {
       m=23;
       n=4;
  }
       else if (year>=1900 and year<=2099) {
       m=24;
       n=5;
  }
  else if (year>=2100 and year<=2199) {
       m=24;
       n=6;
  }
  else if (year>=2200 and year<=2299) {
       m=25;
       n=0;
  }
  else if (year>=2300 and year<=2399) {
       m=26;
       n=1;
  }
  else if (year>=2400 and year<=2499) {
       m=25;
       n=1;
  }
  else {
       cout<<"Data non calcolabile xD";
       return 0;
       }
  d=(19*a+m)%30;
  e = (2*b+4*c+6*d+n)%7;
  if (d+e<10) {
    cout<<"La pasqua è il "<<d+e+22<<" di marzo";
  }
  else {
    if ((d+e-9)==26) {
      cout<<"La pasqua è il 19 aprile";
    }
    else if ((d+e-9)==25 and d==28 and e==6 and a>10) {
      cout<<"La pasqua è il 18 aprile";
    }
    else {
      cout<<"La pasqua è il "<<d+e-9<<" aprile";
    }
  }
  return 0;
}
Ovviamente ho usato Gauss.
 
Stato
Discussione chiusa ad ulteriori risposte.