|
-
Sep 24th, 2009, 12:11 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Help calculating easter date...
Heyy, what's up?
I need some help doing this (it's an assingment, by the way)...
This is my code:
Code:
#include <stdlib.h>
#include <stdio.h>
void main(void){
int d, m, y, o; //day, month year, option
int c,g,k,i,j,l; //variables needed to calculate the date..
tryagain:
printf("Write a year to calculate it's easter date: ", a);
scanf("%d", &a);
if (a < 1000 || a > 9999){
printf("That year is not valid.\n");
printf("Try again (0 = no/1 = yes): ", o);
scanf("%d", &o);
if (o == 1) {
system("CLS");
goto tryagain;
}
else {
printf("Bye Bye...\n");
}
}
else if(a>=1000 && a < 10000){
//Calculation of the easter date...
c = y/100;
g = y % 19;
k = (c - 17)/25;
i = (c - c/4 - (c - k)/3 + 19*g + 15) % 30;
i = i - (i/28)*(1 - (i/28)*(29/(i + 1))*((21 - g)/11));
j = (c + c/4 + i + 2 - c + c/4) % 7;
l = i - j;
m = 3 + (l + 40)/44;
d = l + 28 - 31*(m/4);
m = 3+(l+40)/44;
d=m+28-31*(m/4);
printf("\n==================================\n");
printf("La fecha del Easter es: %d/%d/%d.\n", d, m, c);
printf("==================================\n\n");
}
printf("Go again (0 = no/1 = yes): ", o);
scanf("%d", &o);
if (o == 1) {
system("CLS");
goto tryagain;
}
else {
printf("Bye...\n");
}
system("PAUSE");
return 0;
}
The code prints the same dates... This is based on Oudin's algorithm.
Thanks in advance!
-
Sep 24th, 2009, 04:09 PM
#2
Thread Starter
Fanatic Member
Re: [RESOLVED] Help calculating easter date...
Got it working... This is the code:
vb.net Code:
#include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]){ int d, m, y, o; //day, month year, option int c,g,k,i,j,l; //variables needed to calculate the date.. tryagain: printf("Write a year to calculate it's easter date: ", a); scanf("%d", &a); if (a < 1000 || a > 9999){ printf("That year is not valid.\n"); printf("Try again (0 = no/1 = yes): ", o); scanf("%d", &o); if (o == 1) { system("CLS"); goto tryagain; } else { printf("Bye Bye...\n"); } } else if(a>=1000 && a < 10000){ //Calculation of the easter date... c = y/100; g = y % 19; k = (c - 17)/25; i = (c - c/4 - (c - k)/3 + 19*g + 15) % 30; i = i - (i/28)*(1 - (i/28)*(29/(i + 1))*((21 - g)/11)); j = (c + c/4 + i + 2 - c + c/4) % 7; l = i - j; m = 3 + (l + 40)/44; d = l + 28 - 31*(m/4); printf("\n==================================\n"); printf("La fecha del Easter es: %d/%d/%d.\n", d, m, c); printf("==================================\n\n"); } printf("Go again (0 = no/1 = yes): ", o); scanf("%d", &o); if (o == 1) { system("CLS"); goto tryagain; } else { printf("Bye...\n"); } system("PAUSE"); return 0; }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|