error C2196: case 值“1”已使用 ====了

#include <stdafx.h>
int main()
{
 int year = 2008, month = 8, day = 8, b = 0;
 for (; 1 <= month; month--)
 {
  switch (month)
  {
  case 1 || 3 || 5 || 7 || 8 || 10 || 12:


   b = b + 31;
   break;
  case 2:
   if (year % 4 == 0 && year % 100 !=0 || year % 400 == 0)
    b = b + 29;
   else
    b = b + 28;
   break;
  case 4||6||9||11:
    b = b + 30;
    break;
  }


 }
 printf("%d", b + day);
 return 0;
}


慕粉18341035298
浏览 1880回答 1
1回答

OuBa

#include <stdafx.h> int main() {     int year = 2008;     int month = 8;      int day = 8;     int b = 0;          for (; 1 <= month; month--)     {         switch (month)         {              case 1:              case 3:              case 5:              case 7:              case 8:              case 10:              case 12:              {                  b = b + 31;                  break;              }              case 2:              {                   if (year % 4 == 0 && year % 100 !=0 || year % 400 == 0)                   {                       b = b + 29;                   }                    else                   {                       b = b + 28;                   }                   break;              }              case 4:              case 6:              case 9:              case 11:              {                   b = b + 30;                   break;              }          }      }      printf("%d\n", b + day);      return 0; }
打开App,查看更多内容
随时随地看视频慕课网APP