kqsz127 2015-08-23 08:32 采纳率: 60%
浏览 1775
已采纳

控制台 无输出 但是两个输入都正常

求助

```// 此程序求绝对值

float absolutevalue (float x)
{
if ( x < 0)
x = -x;

return x;

}

//此程序求squreRoot 中 while 循环次数

int times (float esplion){
int i;
while (esplion != 1) {
esplion *= 10;
i ++;
}
return i;
}

//此程序求平方根
float squreRoot (float x, float esplion)
{
float guess = 1.0;

while (absolutevalue (guess*guess - x) >= esplion )
    {
    int i;
     for ( i = 0; i<= times(esplion); i++)
 {  
     guess = (x/guess + guess)/2.0;
     printf ("The guess is %f.\n", guess);
 }
}

return guess; 

}

int main ()
{
printf ("Enter you number : \n");

float x, esplion ;  

scanf ("%f", &x);

printf ("Enter you esplion: \n");

scanf ("%f", &esplion);

printf ("The squreroot of the %f is %f", x, squreRoot (x, esplion));

return 0; 

}


  • 写回答

5条回答

  • 小南家的青蛙 2015-08-23 08:46
    关注

    squreRoot 效率很低,times(esplion)只需要调用一次
    esplion取值不当的话,times方法的实现会导致死循环

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择