下面程序的输出结果是( )

#include <stdio.h>

int main()
{  
int i, n = 0;
float x = 1, y1 = 2.1 / 1.9, y2 = 1.9 / 2.1;

for ( i = 1; i < 22; i++)
x = x * y1;

while ( x != 1.0 )
{ 
x = x * y2; n++;
}

printf( "%d\n", n );

return 0; 
}

答案:程序无线循环
解析:浮点类型不能精确相等

    原文作者:德馨居
    原文地址: https://blog.csdn.net/qq_45616304/article/details/108539601
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞