因為如果沒有break;語句,每個案例都會繼續到下一個案例。 switch((++a)-1) { case 0:printf("\nzero"); // Without a break;, the next line gets executed as well! case 1:printf("%d.one",i+1); // Execution continues here, printing "%d.one", even though we are in case 0 case 2:if(i%2==0) { printf("\n\t%d.Two",i+1); } else { printf("\n%d.Two",i+1); } // The default will get run as well, for lack of a "break;" default:printf("\t%d.step",i+1); } 這應該正確地寫為: switch((++a)-1){ case 0: printf("\nzero"); break; case 1: printf("%d.one",i+1); break; case 2: if(i%2==0) { printf("\n\t%d.Two",i+1); } else { printf("\n%d.Two",i+1); } break;