Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- #include <cmath>
- #include <vector>
- #include <algorithm>
- using namespace std;
- // Čia parašykite funkcijų antraštes
- bool ArTrikampis(int a, int b, int c);
- bool ArIvairiakrastis(int a, int b, int c);
- double TrikampioPlotas(int a, int b, int c);
- int main()
- {
- ofstream rezultatai("Rezultatai4.txt");
- int a, b;
- cout << "Iveskite intervalo pirmaji skaiciu" << endl;
- cin >> a;
- cout << "Iveskite intervalo antraji skaiciu" << endl;
- cin >> b;
- vector<double> plotai;
- for (int x = a; x <= b; x++)
- {
- for (int y = a; y <= b; y++)
- {
- for (int z = a; z <= b; z++)
- {
- if (ArTrikampis(x, y, z) && ArIvairiakrastis(x, y, z))
- {
- if (find(plotai.begin(), plotai.end(), TrikampioPlotas(x, y, z))!= plotai.end())
- continue;
- rezultatai << fixed << setprecision(2) << x << " " << y << " " << z << " " << TrikampioPlotas(x, y, z) << endl;
- plotai.push_back(TrikampioPlotas(x, y, z));
- }
- }
- }
- }
- return 0;
- }
- // Funkcija, patikrinanti, ar galima sudaryti trikampį
- // Funkcija grąžina reikšmę true, jei trikampį sudaryti galima, priešingu atveju – false;
- bool ArTrikampis(int a, int b, int c)
- {
- return ((a + b > c) && (a + c > b) && (b + c > a));
- }
- // Funkcija, patikrinanti, ar trikampis įvairiakraštis
- // Funkcija grąžina reikšmę true, jei trikampis įvairiakraštis, priešingu atveju – false
- bool ArIvairiakrastis(int a, int b, int c)
- {
- return ((a != b) && (b != c) && (c != a));
- }
- // Funkcija, grąžinanti apskaičiuotą trikampio plotą.
- double TrikampioPlotas(int a, int b, int c)
- {
- double s = (a + b + c) / 2.0;
- return sqrt(s * (s - a) * (s - b) * (s - c));
- }
Advertisement
Add Comment
Please, Sign In to add comment