You're here: Snippet Directory » C/C++ (495)
Language:

Wann ist denn eigentlich dieses Jahr Ostern?

Language: Deutsch
Programming Language: C++
Published by: Thomas
Last Update: 5/4/2006
Views: 734

Description

Das Snippet berechnet ausgehend von der Jahreszahl den Zeitpunkt, an dem in diesem Jahr Ostern ist.

Code

1 #include <champ.h> 2 #include "filename.rh" 3 4 5 void gmain () 6 { 7 cinit(); 8 9 long x; 10 11 int a; 12 int b; 13 int c; 14 int d; 15 int e; 16 int f; 17 18 cout <<"Jahrestag?x= "; 19 cin >>x; 20 21 a=x%20; 22 b=x%4; 23 c=x%7; 24 d=(20*a+24)%30; 25 e=((2*b)+(4*c)+(6*d)+5)%7; 26 27 f=22+d+e; 28 29 if(x>2005) 30 { 31 if(21<f&&f<32) 32 { 33 cout << "Ostern wird im Jahr "<<x<<" am "<<(22+d+e)<<" März sein."; 34 } 35 else 36 { 37 cout << "Ostern wird im Jahr "<<x<<" am "<<(d+e-9)<<" April sein."; 38 } 39 } 40 else 41 { 42 if(21<f&&f<32) 43 { 44 cout << "Ostern war im Jahr "<<x<<" am "<<(22+d+e)<<" März."; 45 } 46 else 47 { 48 cout << "Ostern war im Jahr "<<x<<" am "<<(d+e-9)<<" April."; 49 } 50 } 51 52 cgetch(); 53 cend(); 54 }

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS