Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- const char duom[] = "Duomenys.txt";
- const char rez[] = "Rezultatai.txt";
- double krastines_ilgis(int x1, int y1, int x2, int y2) {
- return sqrt( pow(x1-x2, 2) + pow(y1-y2, 2) );
- }
- //Herono formulė
- double plotas(int x1, int y1, int x2, int y2, int x3, int y3) {
- double a = krastines_ilgis(x1, y1, x2, y2);
- double b = krastines_ilgis(x1, y1, x3, y3);
- double c = krastines_ilgis(x2, y2, x3, y3);
- double p = (a+b+c)*0.5;// Pusperimetris
- return sqrt(p*(p-a)*(p-b)*(p-c));
- }
- int main() {
- int x1, y1, x2, y2, x3, y3;
- ifstream in(duom);
- ofstream out(rez);
- while( in >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 )
- out << fixed << setprecision(2) << plotas(x1, y1, x2, y2, x3, y3) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment