kleine Optimierung

This commit is contained in:
Leaced 2017-04-02 17:42:04 +02:00
parent 49a63f9c6b
commit dd1be668ff

View file

@ -59,34 +59,25 @@ int main()
if(month==1 || month==2) year -=1;
switch (month)
{
case 1: month = 0; break;
case 8: month = 1; break;
case 2:
case 6: month = 3; break;
case 9:
case 12: month = 4; break;
case 4:
case 7: month = 5; break;
case 10: month = 6; break;
default: month = 2; break;
}
if(month==1) month = 0;
else if(month==8) month = 1;
else if(month==2 || month==6) month = 3;
else if(month==9 || month==12) month = 4;
else if(month==4 || month==7) month = 5;
else if(month == 10) month = 6;
else month = 2;
weekday = (day+month+(year%100)+(year%100/4)+year/400-2*(year/100))%7;
while(weekday<0) weekday += 7;
switch(weekday)
{
case 0: std::cout << "Sonntag"; break;
case 1: std::cout << "Montag"; break;
case 2: std::cout << "Dienstag"; break;
case 3: std::cout << "Mittwoch"; break;
case 4: std::cout << "Donnerstag"; break;
case 5: std::cout << "Freitag"; break;
case 6: std::cout << "Samstag"; break;
}
if(weekday==0) std::cout << "Sonntag";
else if(weekday==1) std::cout << "Montag";
else if(weekday==2) std::cout << "Dienstag";
else if(weekday==3) std::cout << "Mittwoch";
else if(weekday==4) std::cout << "Donnerstag";
else if(weekday==5) std::cout << "Freitag";
else std::cout << "Samstag";
getch();
return(0);