OOP HomeWork
This commit is contained in:
11
oop_hw1/oop_hw1_4/main.cpp
Normal file
11
oop_hw1/oop_hw1_4/main.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <iostream>
|
||||
#include "t_area.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
double a, b, c;
|
||||
cin >> a >> b >> c;
|
||||
cout << triangle_area(a,b,c) << endl;
|
||||
return 0;
|
||||
}
|
5
oop_hw1/oop_hw1_4/t_area.cpp
Normal file
5
oop_hw1/oop_hw1_4/t_area.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <cmath>
|
||||
double triangle_area(double a, double b, double c) {
|
||||
double s = (a + b + c) / 2;
|
||||
return sqrt(s * (s - a) * (s - b) * (s - c));
|
||||
}
|
8
oop_hw1/oop_hw1_4/t_area.h
Normal file
8
oop_hw1/oop_hw1_4/t_area.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#ifndef tarea
|
||||
#define tarea
|
||||
|
||||
double triangle_area(double a, double b, double c);
|
||||
|
||||
|
||||
#endif // !tarea
|
Reference in New Issue
Block a user