题解 | 计算三角形的周长和面积

计算三角形的周长和面积

https://www.nowcoder.com/practice/109a44d649a142d483314e8a57e2c710

#include <math.h>
#include <stdio.h>

int main() {
    int a, b, c = 0;
    do {
        scanf("%d %d %d", &a, &b, &c);
    } while (a + b <= c || a + c <= b || b + c <= a);
    float circumference = 0;//周长
    float area = 0;
    float half_circumference = 0;//半周长——>用来计算面积
    half_circumference = (a + b + c) * 1.0 / 2;
    circumference = a + b + c;
    area = sqrt(half_circumference * (half_circumference - a) * (half_circumference - b) * (half_circumference - c));
    printf("circumference=%.2f area=%.2f", circumference, area);
    return 0;
}

全部评论

相关推荐

秒拒也太伤人心了
码农索隆:非得字节嘛
投递字节跳动等公司10个岗位
点赞 评论 收藏
分享
05-29 20:34
门头沟学院 C++
KarlAllen:得做好直接春招的准备。学历差的话,一是面试要求会比学历好的严格不少,二是就算面试通过了也会被排序。总之暑期和秋招对于学历差的就是及其不友好
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务