在Linux中使用sqrt

在Linux中使用sqrt,第1张

int main(int argc, char const *argv[])
{
    int i,x,y;
    for (i=1;i<100;i++)
    { 
        x=sqrt(i+100);                                  //x 是i + 100 后开方的结果//
        y=sqrt(i+268);                                  //y 是i + 168 后开方的结果//

        if( x*x == i+100 && y*y == i+268)
        {
            printf("\n%ld\n",i);
        }
        
    }
    return 0;
    
}

解决:

编译的时候在命令后加上 -lm 即可:gcc test.c -lm

完。。。。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/875170.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-13
下一篇 2022-05-13

发表评论

登录后才能评论

评论列表(0条)

保存