B. Hàm tính diện tích Tam giác


Submit solution

Points: 50
Time limit: 1.0s
Memory limit: 256M

Problem type

Mô tả: Viết hàm dienTichTamGiac(double a, double h) trả về diện tích tam giác theo công thức:

S = ½ × a × h

Đầu vào:

  • Hai số thực a, h (0 < a, h ≤ 10^9)

Đầu ra:

  • Diện tích tam giác (in ra 1 chữ số thập phân)

Test Case:

Input Output Giải thích
10 5 25.0 ½ × 10 × 5 = 25.0
6.5 3.2 10.4 ½ × 6.5 × 3.2 = 10.4

Code C++ hướng dẫn:

#include <iostream>
#include <iomanip>
using namespace std;

// Hàm tính diện tích tam giác
double dienTichTamGiac(double a, double h) {
    return 0.5 _____;
}

int main() {
    double a, h;
    cin >> a >> h;
    ____ s = dienTichTamGiac(___,____);
    cout << fixed << setprecision(1) << ____
    return 0;
}

Comments

There are no comments at the moment.