Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Trougao{
- float x,y,z,s;
- float povrsina,obim;
- bool jelTrougao = false;
- public:
- Trougao(){
- x = 0;
- y = 0;
- z = 0;
- }
- Trougao(float xu, float yu, float zu) {
- x = xu;
- y = yu;
- z = zu;
- s = (x+y+z) / 2;
- if (DaLiJeTrougao(x, y, z)) {
- cout << "Trougao postoji.\n";
- } else cout << "Trougao ne postoji.\n";
- povrsina = sqrt(s * (s-x)* (s-y)* (s-z));
- cout << "Povrsina je " << povrsina;
- obim = x + y + z;
- cout << "\nObim je " << obim;
- }
- bool DaLiJeTrougao(float a, float b, float c) {
- if (a < b+c && b < a+c && c < b+c) {
- jelTrougao = true;
- return true;
- } else {
- jelTrougao = false;
- return false;
- }
- }
- void unesiStranice(float a, float b, float c){
- x = a;
- y = b;
- z = c;
- s = (x+y+z) / 2;
- DaLiJeTrougao(x, y, z);
- povrsina = sqrt(s * (s-x)* (s-y)* (s-z));
- obim = x + y + z;
- }
- float vratiPovrsinu(){
- return povrsina;
- }
- float vratiObim(){
- return obim;
- }
- };
- int main()
- {
- float a,b,c;
- cout << "Unesi stranicu A:";
- cin >> a;
- cout << "Unesi stranicu B:";
- cin >> b;
- cout << "Unesi stranicu C:";
- cin >> c;
- Trougao tr(a, b, c);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement