Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class Pravokotnik {
- int visina, dolzina;
- public:
- Pravokotnik();
- Pravokotnik(int a);
- Pravokotnik(int a, int b);
- int ploscina () {return dolzina*visina;}
- int obseg () {return 2*dolzina+2*visina;}
- int diagonala () {return sqrt(dolzina*dolzina+visina*visina);}
- };
- Pravokotnik::Pravokotnik(){
- this->visina=1;
- this->dolzina=1;
- }
- Pravokotnik::Pravokotnik(int a){
- this->visina=a;
- this->dolzina=a;
- }
- Pravokotnik::Pravokotnik(int a, int b){
- this->visina=a;
- this->dolzina=b;
- }
- int main () {
- double x,y,i;
- cout<<"Podaj dimezijo za 2 pravokotnik"<<endl;
- cin>>i;
- cout<<"Podaj dimeziji za 3 pravokotnik"<<endl;
- cin>>x;
- cin>>y;
- Pravokotnik ena();
- Pravokotnik dva(i);
- Pravokotnik tri(x,y);
- cout<<"Pravokotnik 2"<<endl;
- cout << "Ploscina: " << dva.ploscina() << endl;
- cout << "Obseg: " << dva.obseg() << endl;
- cout << "Diagonala: " << dva.diagonala() << endl;
- cout<<endl;
- cout<<"Pravokotnik 3"<<endl;
- cout << "Ploscina: " << tri.ploscina() << endl;
- cout << "Obseg: " << tri.obseg() << endl;
- cout << "Diagonala: " << tri.diagonala() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement