Jump to content

SUBIECTE NOI
« 1 / 5 »
RSS
Frecventa modificata radio

Un nou pericol pt batrani

Ar trebuii sa vindem imobiliarele...

Dupa renuntarea la aparat dentar
 pelerinaj in Balcik

Noul format Jpegli iși propu...

Dade, dade

Parola la lock screen
 Deparazitare externa pisici fara ...

Seriale turcesti/coreene online H...

Merita un Termostat Smart pentru ...

Sfat achizitie MTB Devron Riddle
 Problema mare cu parintii= nervi ...

switch microtik

Permis categoria B la 17 ani

Sfaturi pentru pregatirea de eval...
 

C | Problema de calculare a datei Pastelui catolic

- - - - -
  • Please log in to reply
5 replies to this topic

#1
andreixdebu

andreixdebu

    New Member

  • Grup: Candidate Members
  • Posts: 5
  • Înscris: 23.02.2022
Salut, am un program care ar trebui sa calculeze data Pastelui catolic dupa citirea unui an. Am sa va postez cerinta si ce am incercat sa fac, nu imi iese bine data la unii ani, daca puteti sa ma ajutati va rog sa vedeti ce am facut gresit.


This program takes as command line a single integer value which represents a year and then computes and displays the Easter date for that year
The algorithm for computing the catholic Easter date is the following :
A = year mod 19
B = year mod 4
C = year mod 7
D = (19 * A + 24) mod 30
E = (2 * B + 4 * C + 6 * D + 5) mod 7 where mod is the remainder of the division of x to y.
Easter day is then(22 + E + D) March. Note that this formula can give a date from April if 22 + E + D > 31; also take this case into account!
The program will display the Easter date in the following way "The Easter day is 02 April " (use trailing zeros for the day if it is less than 10)

#include <stdio.h>
#include <stdlib.h>
int main() {
int Easter;
int x,y;
scanf("%i",&x);
int A,B,C,D,E;
A = x % 19;
B = x % 4;
C = x % 7;
D = (19 * A + 24) % 30;
E = (2 * B + 4 * C + 6 * D + 5) % 7;
Easter = (22 + E + D);
if(Easter <= 31)
{
if (Easter < 10)
printf("The Easter day is 0%i March", Easter);
else
printf("The Easter day is %i March", Easter);
}
else
{
y = Easter - 31;
if (y < 10)
printf("The Easter day is 0%i April", y);
else
printf("The Easter day is %i April", y);
}
return 0;
}


Multumesc anticipat!

#2
_bcristian_

_bcristian_

    Senior Member

  • Grup: Senior Members
  • Posts: 3,569
  • Înscris: 31.12.2006
Din ce vad, programul e corect.
Doar ca algoritmul e incomplet si limitat:

Quote


The date of the Easter Sunday can be calculated using the following method derived from the original algorithm by Carl Friedrich Gauss. The algorithm can be applied to the Gregorian calendar for years 1900-2099. The date given by the algorithm is used in Western Christian churches, the date used by the Eastern churches can be 1, 4 or 5 weeks later. More comprehensive forms (including years 1583-9999) of the algorithm exist but they include lenghty tables of Epact and Sunday Letter constants so I won't add them here.
a = year mod 19 (use year in four digits)
b = year mod 4
c = year mod 7
d = (24+19a) mod 30
e = (5+2b+4c+6d) mod 7
Easter Sunday is on the (22+d+e) of March or on the (d+e-9) of April, depending on which answer is a valid date. If the date given by the algorithm is 26th of April, the Easter Sunday is on 19th of April. If the date is 25th of April and d=28 and a>10, the Easter Sunday is on 18th of April.


#3
MarianG

MarianG

    be that as it may

  • Grup: Moderators
  • Posts: 31,443
  • Înscris: 10.08.2005
printf stie de leading zeros
printf("%02d\n",numar)
Tu trebuie sa determini in ce luna pica sarbatoarea.

#4
Webbbob

Webbbob

    Member

  • Grup: Members
  • Posts: 636
  • Înscris: 22.03.2019
sunt librarii cu care lucrezi cu date/datetime, ce faci tu se numeste reinventarea rotii.

#5
MarianG

MarianG

    be that as it may

  • Grup: Moderators
  • Posts: 31,443
  • Înscris: 10.08.2005
Omul din greseli invata.

#6
MarianG

MarianG

    be that as it may

  • Grup: Moderators
  • Posts: 31,443
  • Înscris: 10.08.2005
if (day > 31)
	{
		day-=31;
		sprintf(month,"%s","April");
	}
	printf ("%02d %s\n", day, month);

mai putine if-uri, mai putina bataie de cap

View Post_bcristian_, on 23 februarie 2022 - 13:24, said:

Doar ca algoritmul e incomplet si limitat:
Biserica si cazurile ei speciale.

Edited by MarianG, 23 February 2022 - 19:54.


Anunturi

Chirurgia cranio-cerebrală minim invazivă Chirurgia cranio-cerebrală minim invazivă

Tehnicile minim invazive impun utilizarea unei tehnologii ultramoderne.

Endoscoapele operatorii de diverse tipuri, microscopul operator dedicat, neuronavigația, neuroelectrofiziologia, tehnicile avansate de anestezie, chirurgia cu pacientul treaz reprezintă armamentarium fără de care neurochirurgia prin "gaura cheii" nu ar fi posibilă. Folosind tehnicile de mai sus, tratăm un spectru larg de patologii cranio-cerebrale.

www.neurohope.ro

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Forumul Softpedia foloseste "cookies" pentru a imbunatati experienta utilizatorilor Accept
Pentru detalii si optiuni legate de cookies si datele personale, consultati Politica de utilizare cookies si Politica de confidentialitate