" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
#include<cstdlib>
#include<cmath>
using namespace std;
float Dlugosci[3];
int X1, Y1, X2, Y2;
float obliczDlugosc(int x1, int y1, int x2, int y2) {
return sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
}
////sortowanie tablicy
void zamien(float &a, float &b){
int temp=a;
a=b;
b=temp;
}
void sortowanie(float tab[]) {
int temp;
for (int j=2; j>0; j--) {
for (int i=0; i<j; i++)
if (tab [i]>tab[i+1])
zamien (tab [i], tab[i+1]); }
}
////sortowanie
bool sprawdz(float tab[]) {
return tab[2] > tab[0]+tab[1];
}
int main() {
for(int i = 0; i<3; ++i){
system("cls");
cout << i+1 << ". bok" << endl;
cout << "Podaj wspolrzedne pierwszego wierzcholka" << endl;
cout << "x1: ";
cin >> X1;
cout << "y1: ";
cin >> Y1;
cout << "Podaj wspolrzedne drugiego wierzcholka" << endl;
cout << "x2: ";
cin >> X2;
cout << "y2: ";
cin >> Y2;
Dlugosci[i] = obliczDlugosc(X1, Y1, X2, Y2);
}
system("cls");
cout << "1. bok = " << Dlugosci[0] << endl;
cout << "2. bok = " << Dlugosci[1] << endl;
cout << "3. bok = " << Dlugosci[2] << endl << endl;
sortowanie(Dlugosci);
if(!sprawdz)
cout << "Jest mozliwe utworzenie trojkata" <<;
else
cout << "Nie jest mozliwe utworzenie trojkata";
cout << endl << endl;
system("pause");
return 0;
}