帮忙找个错!
#include <stdio.h>#include <math.h>
#include<conio.h>
main()
{long int x,y,r1,r2;
printf("please input x and r\n");
scanf("%ld%ld",&x,&r1);
printf("%ld,%ld\n",x,r1);
y=r1*x/(x-r1);
if(y<0)
printf("y is unknow");
else
{printf("the y resistance is %ld\n",y);
printf("input y resestance you have choiced\n");
scanf("%ld",&y);
r2=x*y/(x+y);
printf("%ld\n",r2);
}
getch();
}
源程序如上,当输入x和r1后显示结果y为25000再次输入y 值结果确实 -17174.找了半天没找到问题在哪里,正数的乘加除结果应该还是个正数啊?各位帮忙分析下。谢谢!