标题:大师们,求围观!!!
只看楼主
lbt001
Rank: 1
等 级:新手上路
帖 子:26
专家分:4
注 册:2015-2-3
结帖率:62.5%
已结贴  问题点数:20 回复次数:6 
大师们,求围观!!!
local variable 'b' used without having been initialized
 local variable 'a' used without having been initialzed
 warning C4700: local variable 'c' used without having been initialized
我的程序一直是输出“无解”
# include <stdio.h>
# include <math.h>
int main(void)
{
    double a,b,c;
    double x1,x2;
    double delta;
   
    printf("请输入三个数值\n");
    delta = b * b - 4 * a * c ;
    printf("a = ");
    scanf("%lf",&a);
    printf("b = ");
    scanf("%lf",&b);
    printf("c = ");
    scanf("%lf",&c);
    do
    {
    if(delta > 0)
    {
        x1 = (-b+sqrt(delta))/(2*a);
        x2 = (-b-sqrt(delta))/(2*a);
        printf("x1= %lf,x2 = %lf\n",x1,x2);

    }
    if(delta == 0)
    {
        x1 = (-b)/(2*a);
        x2 = x1;
        printf("x1 = x2 =%lf\n");


    }
    else if(delta < 0)
    {

        printf("无解\n");

    }
    }while(1);


    return 0;
}
搜索更多相关主题的帖子: include warning without double having 
2015-02-16 22:10
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
得分:4 
圍觀過了

授人以渔,不授人以鱼。
2015-02-16 22:13
longwu9t
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:6
帖 子:732
专家分:2468
注 册:2014-10-9
得分:4 
程序代码:
# include <stdio.h>
# include <math.h>

int main(void) {
    double a, b, c;
    double x1, x2;
    double delta;
    printf("请输入三个数值\n");
    printf("a = ");
    scanf("%lf", &a);
    printf("b = ");
    scanf("%lf", &b);
    printf("c = ");
    scanf("%lf", &c);
    delta = b * b - 4 * a * c ;

    if(delta > 0) {
        x1 = (-1 * b + sqrt(delta)) / (2 * a);
        x2 = (-1 * b - sqrt(delta)) / (2 * a);
        printf("x1 = %f, x2 = %f\n", x1, x2);

    } else if(delta == 0) {
        x1 = (-1 * b) / (2 * a);
        printf("x1 = x2 = %f\n", x1);

    } else {
        printf("无实数解\n");
    }

    return 0;
}


Only the Code Tells the Truth             K.I.S.S
2015-02-16 22:20
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
得分:4 
围观
2015-02-16 22:26
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
得分:4 
楼主过年好
2015-02-16 22:34
hzg123
Rank: 2
等 级:论坛游民
帖 子:8
专家分:34
注 册:2015-2-16
得分:4 
# include <stdio.h>
# include <math.h>
int main(void)
{
    double a,b,c;
    double x1,x2;
    double delta;
    do{
    printf("请输入三个数值\n");
       //delta = b * b - 4 * a * c ;
    printf("a = ");
    scanf("%lf",&a);
    printf("b = ");
    scanf("%lf",&b);
    printf("c = ");
    scanf("%lf",&c);

    delta = b * b - 4 * a * c ;//delta值是建立在a,b,c有值的基础上,不能写在a,b,c无值情况下
    if(delta > 0)
    {
        x1 = (-b+sqrt(delta))/(2*a);
        x2 = (-b-sqrt(delta))/(2*a);
        printf("x1= %lf,x2 = %lf\n",x1,x2);

    }
   else if(delta == 0)
    {
        x1 = (-b)/(2*a);
        x2 = x1;
        printf("x1 = x2 =%lf\n");


    }
    else
    {

        printf("无解\n");

    }}while(1);


    return 0;
}
收到的鲜花
  • lbt0012015-02-20 22:14 送鲜花  3朵  
2015-02-17 09:10
诸葛欧阳
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:流年
等 级:贵宾
威 望:82
帖 子:2790
专家分:14619
注 册:2014-10-16
得分:4 
围观,我就看看不说话

一片落叶掉进了回忆的流年。
2015-02-17 11:05



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




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

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