Remember that default
can be used for performing a task when none of the cases is true:
switch (x)
{
case 1:
case 2:
printf("%d
", x);
break;
default:
if (islower(x))
{
puts("alpha");
}
break;
}
Another way using the infamous goto
:
if (islower(x))
goto alpha;
switch (x)
{
alpha:
printf("alpha
");
break;
case 1:
case 2:
printf("%d
", x);
break;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…