| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 781 人关注过本帖
标题:我是大一新生,求大神教育
只看楼主 加入收藏
记忆回不去
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-11-8
结帖率:0
收藏
已结贴  问题点数:10 回复次数:11 
我是大一新生,求大神教育
这是我编的
/*给10z组a b c求证若组成三角形求其周长 面积(精确小数点两位) 不成立输出a b c*/
#include<stdio.h>
#include<math.h>
int main(void)
{
    int i;
    double a,s,b,c,m,area;    /*m为周长,area为面积*/
    for(i=1;i<=10;i++){
        printf("enter a b c:");
        scanf("a=%lf,b=%lf,c=%lf\n",a,b,c);
        if(a+b>c&&a-b<c){
            m=a+b+c;
            s=(a+b+c)/2;
            area=sqrt(s*(s-a)*(s-b)*(s-c));
            printf("m=%.2f,area=%.2f\n",m,area);
        }
        else{
            printf("a=%.2f,b=%.2f,c=%.2f\n",a,b,c);
        }
    }
    return 0;
}
输出结果是乱码 好多数字
                enter a b c:4 5 6
a=-92559631349317831000000000000000000000000000000000000000000000.00,b=-92559631
349317831000000000000000000000000000000000000000000000.00,c=-9255963134931783100
0000000000000000000000000000000000000000000.00
enter a b c:a=-92559631349317831000000000000000000000000000000000000000000000.00
,b=-92559631349317831000000000000000000000000000000000000000000000.00,c=-9255963
1349317831000000000000000000000000000000000000000000000.00
enter a b c:a=-92559631349317831000000000000000000000000000000000000000000000.00
,b=-92559631349317831000000000000000000000000000000000000000000000.00,c=-9255963
1349317831000000000000000000000000000000000000000000000.00
enter a b c:a=-92559631349317831000000000000000000000000000000000000000000000.00
,b=-92559631349317831000000000000000000000000000000000000000000000.00,c=-9255963
1349317831000000000000000000000000000000000000000000000.00
enter a b c:a=-92559631349317831000000000000000000000000000000000000000000000.00
,b=-92559631349317831000000000000000000000000000000000000000000000.00,c=-9255963
1349317831000000000000000000000000000000000000000000000.00
enter a b c:a=-92559631349317831000000000000000000000000000000000000000000000.00
,b=-92559631349317831000000000000000000000000000000000000000000000.00,c=-9255963
1349317831000000000000000000000000000000000000000000000.00
enter a b c:a=-92559631349317831000000000000000000000000000000000000000000000.00
,b=-92559631349317831000000000000000000000000000000000000000000000.00,c=-9255963
1349317831000000000000000000000000000000000000000000000.00
enter a b c:a=-92559631349317831000000000000000000000000000000000000000000000.00
,b=-92559631349317831000000000000000000000000000000000000000000000.00,c=-9255963
1349317831000000000000000000000000000000000000000000000.00
enter a b c:a=-92559631349317831000000000000000000000000000000000000000000000.00
,b=-92559631349317831000000000000000000000000000000000000000000000.00,c=-9255963
1349317831000000000000000000000000000000000000000000000.00
enter a b c:a=-92559631349317831000000000000000000000000000000000000000000000.00
,b=-92559631349317831000000000000000000000000000000000000000000000.00,c=-9255963
1349317831000000000000000000000000000000000000000000000.00
Press any key to continue

搜索更多相关主题的帖子: 大一新生 include 三角形 
2012-11-08 03:22
StarFall
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:193
专家分:553
注 册:2012-10-1
收藏
得分:2 
赋值语句错了。应该是&a,&b,&c

去追寻更高的技术领域。永不停止。
2012-11-08 05:39
臧月亮
Rank: 2
等 级:论坛游民
帖 子:11
专家分:13
注 册:2012-11-4
收藏
得分:2 
在scanf中缺少了取地址符&    否则你输入的数据会找不到内存地址,应该是&a ,&b, &c ,自己再运行一下看看,水平所限,我也只能帮你这些
2012-11-08 08:51
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:2 
#include<stdio.h>
#include<math.h>
int main(void)
{
    int i;
    double a,s,b,c,m,area;    /*m为周长,area为面积*/
    for(i=1;i<=10;i++){
        printf("enter a b c:");
        scanf("%lf,%lf,%lf",&a,&b,&c);
        if(a+b>c&&a-b<c){
            m=a+b+c;
            s=(a+b+c)/2;
            area=sqrt(s*(s-a)*(s-b)*(s-c));
            printf("m=%.2f,area=%.2f\n",m,area);
        }
        else{
            printf("a=%.2f,b=%.2f,c=%.2f\n",a,b,c);
        }
    }
    return 0;
}

DO IT YOURSELF !
2012-11-08 09:27
浅唱我的Time
Rank: 7Rank: 7Rank: 7
等 级:黑侠
帖 子:98
专家分:562
注 册:2012-9-24
收藏
得分:2 
回复 楼主 记忆回不去
/*给10z组a b c求证若组成三角形求其周长 面积(精确小数点两位) 不成立输出a b c*/
#include<stdio.h>
#include<math.h>
int main(void)
{
    int i;
    double a,s,b,c,m,area;    /*m为周长,area为面积*/
    for(i=1;i<=10;i++){
        printf("enter a b c:");
        scanf("a=%lf,b=%lf,c=%lf\n",a,b,c);
        if(a+b>c&&a-b<c){
            m=a+b+c;
            s=(a+b+c)/2;
            area=sqrt(s*(s-a)*(s-b)*(s-c));
            printf("m=%.2f,area=%.2f\n",m,area);
        }
        else{
            printf("a=%.2f,b=%.2f,c=%.2f\n",a,b,c);
        }
    }
    return 0;
}


scanf("a=%lf,b=%lf,c=%lf\n",a,b,c);你的这句错了,再好好看看

[ 本帖最后由 浅唱我的Time 于 2012-11-8 09:58 编辑 ]
2012-11-08 09:31
记忆回不去
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-11-8
收藏
得分:0 
回复 5楼 浅唱我的Time
这个问题我改过了  不过输出的还是乱码
2012-11-08 13:21
记忆回不去
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-11-8
收藏
得分:0 
我还分开搞/*给10z组a b c求证若组成三角形求其周长 面积 b不成立输出a b c*/
#include<stdio.h>
#include<math.h>
int main(void)
{
    int i;
    double a,s,b,c,m,area;    /*m为周长,area为面积*/
    for(i=1;i<=10;i++){
        printf("enter a:");
        scanf("\n",&a);
        printf("enter b:");
        scanf("\n",&b);
        printf("enter c:");
        scanf("\n",&c);
        if(a+b>c&&a+c>b&&b+c>a){
            m=a+b+c;
            s=(a+b+c)/2;
            area=sqrt(s*(s-a)*(s-b)*(s-c));
            printf("m=%f,area=%f\n",m,area);
        }
        else{
            printf("a=%f,b=%f,c=%f\n",a,b,c);
        }
    }
    return 0;
}
2012-11-08 13:28
qunxingw
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:24
帖 子:1676
专家分:7295
注 册:2011-6-30
收藏
得分:2 
输入语句格式。相关变量初始化。

www.qunxingw.wang
2012-11-08 14:54
xlc2845
Rank: 2
等 级:论坛游民
帖 子:18
专家分:36
注 册:2012-10-20
收藏
得分:2 
a=3,b=4,c=5
按照你scanf里的格式输入
2012-11-08 15:12
xlc2845
Rank: 2
等 级:论坛游民
帖 子:18
专家分:36
注 册:2012-10-20
收藏
得分:0 
#include<stdio.h>
#include<math.h>
int main()
{
    int i;
    double a,s,b,c,m,area;    /*m为周长,area为面积*/
    for(i=1; i<=10; i++)
    {
        printf("enter a b c:");
        scanf("a=%lf,b=%lf,c=%lf",&a,&b,&c);
        getchar();
        if(a+b>c&&a-b<c)
        {
            m=a+b+c;
            s=(a+b+c)/2;
            area=sqrt(s*(s-a)*(s-b)*(s-c));
            printf("m=%.2f,area=%.2f\n",m,area);
        }
        else
            printf("a=%.2f,b=%.2f,c=%.2f\n",a,b,c);
    }
    return 0;
}
2012-11-08 15:16
快速回复:我是大一新生,求大神教育
数据加载中...
 
   



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

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