c语言编程求组,程序无语句问题但无法达到预定结果。
各位大神,编制了如下一段函数,没有编译错误,但无法实现预定功能,麻烦各位帮忙看看,谢谢!例如我输入传动比i=0.2,至少应该有a=20,b=100这组结果,但程序组建过后一直显示else语句“无合适挂轮”
#include<stdio.h>
#include<math.h>
void main()
{
double i;
int a,b,A,B;
int Z[81]={20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,
43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,
66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,
89,90,91,92,93,94,95,96,97,98,99,100};
printf("请输入差动传动比i:");
scanf("%f",&i);
for(A=0;A<=80;A++)
{
a=Z[A];
for(B=0;B<=80;B++)
{
b=Z[B];
if(fabs(i-a*1.0/b)<=0.001)
{
printf("合适挂轮为a=%d,b=%d\n",a,b);
printf("传动比i绝对值误差%f\n",fabs(i-a*1.0/b));
}
else
printf("无合适挂轮\n") ;
}
}
}