这段代码因该使用if 而不是 switch(){}
强行使用 switch(){} ,没有任何意义
/* 无聊的 switch(){} 版 */
#include
int main(void)
{
int x, y;
int c;
scanf("%d", &x);
if(x < 1)
c = 1;
else if(x < 10)
c = 2;
else
c = 3;
switch(c)
{
case 1:
y = x;
printf("x=%3d, y=x=%d\n",x,y);
break;
case 2:
y = 2*x-1;
printf("x=%3d, y=2*x-1=%d\n",x,y);
break;
case 3:
y = 3*x-11;
printf("x=%3d, y=3*x-11%d\n",x,y);
break;
}
return 0;
}
/* 搂主因该去了解一下 switch(){} 的语法 */
[此贴子已经被作者于2007-11-11 20:58:48编辑过]