为什么在这个程序中d=2执行case2,d=4执行case3?怎样使d=2执行case1?
#include <stdio.h>
void main ()
{
double td[4][20] =
{0.3,0.5,0.8,1.2,2,3,4,6,10,14,25,40,60,0.10,0.14,0.25,0.40,0.60,1.0,1.4,
0.4,0.6,1,1.5,2.5,4,5,8,12,18,30,48,75,0.12,0.18,0.30,0.48,0.75,1.2,1.8,
0.4,0.6,1,1.5,2.5,4,6,9,15,22,36,58,90,0.15,0.22,0.36,0.58,0.90,1.5,2.2,
0.5,0.8,1.2,2,3,5,8,11,18,27,43,70,110,0.18,0.27,0.43,0.70,1.10,1.8,2.7,};
int it, d = 0, n = 0;
printf("输入公称尺寸:");
scanf("%d",&d);
printf("输入公差等级:IT");
scanf("%d",&it);
switch(d)
{
case 1:
d > 0&&d <= 3;n = 0;break;
case 2:
d > 3&&d <= 6;n = 1;break;
case 3:
d > 6&&d <= 10;n = 2;break;
case 4:
d > 10&&d <= 18;n = 3;break;
default:printf ("\n输入错误!请重新输入。");
}
if (d > 0&&d <= 18)
printf("尺寸%d的IT%d公差是:%lf",d,it,td[n][it+1]);
}