?
Also, soweit ich das sehe, hab ich ihn fertig...
muss als nächstes dann die bestimmten funktionen auslagern damit es nicht mehr so "lastig ist".
Ich will ja für ein gegebenes datum den wochentag berechnen, mit dem untenstehenden code geht es. Jetzt siehst du wohl auch (D)Evil für was ich das month und month_value zeugs brauche. Da ich mit arrays und pointer noch nicht so sattelfest bin, weiss ich eben nicht, wie ich dann genau denn monat weiter unten wieder einbau, der als input kam...
#include <iostream>
int main()
{ int month;
int day;
int year;
std::cout << "The number of your day in month? ";
std::cin >> day;
do{
std::cout << "The number of your month? ";
std::cin >> month;
} while (month <=0 || month >=13);
do{
std::cout << "The number of the year (>= 1900)? ";
std::cin >> year;
} while (year <1900);
// Berechnung der legalen Tage
if (month == 2){
bool is_leap_year = ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
if (is_leap_year == true){
if (day <1 || day >= 30)
std::cout << "Your date is not correct.";
}
else {
if (day <1 || day >= 29)
std::cout << "Your date is not correct";
}
}
// Monate mit 31 Tagen
if (month != 4 && month != 6 && month != 9 && month !=11 && month !=2){
if (day <1 || day >= 32)
std::cout << "Your date is not correct";
}
// Monate mit 30 Tagen
if (month == 4 || month == 6 || month == 9 || month ==11){
if (day <1 || day >= 31)
std::cout << "Your date is not correct";
}
// Computation
int HH = year/100;
int YY = year%100;
int DD = day;
int month_value;
int corrigendum;
int leap_year_corr=0;
// month assignement
if (month ==1)
month_value =0;
else if (month ==2 || month==3 || month==11)
month_value = 3;
else if (month ==4 || month==7)
month_value =6;
else if (month ==5 )
month_value =1;
else if (month ==6)
month_value =4;
else if (month ==8)
month_value =2;
else if (month==8)
month_value = 2;
else if (month==9 || month==12)
month_value = 5;
else if (month==10)
month_value = 0;
// correction
if (HH%4==1)
corrigendum=4;
else if (HH%4==2)
corrigendum=2;
else if (HH%4==3)
corrigendum=0;
else if (HH%4==0)
corrigendum=6;
// Spec. correction
if (month == 2 && day == 29){
bool is_leap_year = ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
if (is_leap_year == true){
(leap_year_corr)++;
}
}
int year_value = (YY+(YY/4))%7;
int week_day= year_value+month_value + DD + corrigendum - leap_year_corr;
week_day=week_day%7;
// Output
const char* entire_days[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
if (week_day < 12)
std::cout << "Your given date has been evaluated as a " << entire_days[week_day] << ". ";
return 0;
}