?
toller gast, da gast verg schrieb:
Hallo Leute,
So geht das ganze etwas übersichtlicher, diese switch case Verschachtelung ist ja wirlich nichts fürs Auge:
1 int days_of_month(int month, int year){
2 // Monat: 1 2 3 4 5 6 7 8 9 10 11 12
3 char months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
4 return month == 2 && is_leap_year(year) ? 29 : month[i];
5 }
<error detected>
month[i]
<starting auto reparation routine>
... SUCCESS
<showing reparation result>
month[i] replaced by months[month]