标题:加个主函数!!!高手来
取消只看楼主
renzheuwi
Rank: 1
来 自:山西
等 级:新手上路
帖 子:80
专家分:0
注 册:2007-6-28
 问题点数:0 回复次数:0 
加个主函数!!!高手来
void solv_quadr_equa (float a,float b,float c)
{
    if(a==0)
        if(b==0)
            printf("no answer due to input error\n");
        else
            printf("the single root is %f\n",-c/b);
    else
    {double disc,twoa,term1,term2;
    disc=b*b-4*a*c;
    twoa=2*a;
    term1=-b/twoa;
    term2=sqrt (fabs (disc)/twoa;
    if(disc<0.0)
        printf("complex root:\n real part=%f,imag part=%f\n",term1,term2);
    else
        printf("real root:\n root1=%f,root2=%f\n",term1+term2,term1-term2);
        
        }
搜索更多相关主题的帖子: 函数 disc float part 
2008-04-11 09:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-208352-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.980037 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved