kleine Optimierung
This commit is contained in:
parent
49a63f9c6b
commit
dd1be668ff
1 changed files with 14 additions and 23 deletions
|
@ -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);
|
||||
|
|
Reference in a new issue