if语句和switch语句对比

int day = 0;

scanf("%d", &day);

if (1 == day)

printf("星期一\n");

if (2 == day)

printf("星期二\n");

if (3 == day)

printf("星期三\n");

if (4 == day)

printf("星期四\n");

if (5 == day)

printf("星期五\n");

if (6 == day)

printf("星期六\n");

if (7 == day)

printf("星期七\n");

int day = 0;

scanf("%d", &day);

switch (day)

{

case 1:

printf("星期一\n");

break;

case 2:

printf("星期二\n");

break;

case 3:

printf("星期三\n");

break;//终止语句

case 4:

printf("星期四\n");

break;

case 5:

printf("星期五\n");

break;

case 6:

printf("星期六\n");

break;

case 7:

printf("星期天\n");

break;

}