| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 781 人关注过本帖
标题:我是大一新生,求大神教育
取消只看楼主 加入收藏
记忆回不去
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-11-8
结帖率:0
收藏
已结贴  问题点数:10 回复次数: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;
}
输出结果是乱码 好多数字
                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
记忆回不去
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
快速回复:我是大一新生,求大神教育
数据加载中...
 
   



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

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