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