Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class figura
- {
- public:
- string nazwa;
- int ilosc_bokow;
- };
- class trojkat : public figura
- {
- private:
- double a;
- double b;
- double c;
- double wys;
- public:
- void podaj_boki();
- void podaj_wys();
- void wyswietl_boki();
- double pole();
- double obwod();
- double suma_katow();
- trojkat();
- };
- trojkat::trojkat()
- {
- ilosc_bokow = 3;
- }
- void trojkat::podaj_boki()
- {
- cout << "Podaj a: " << endl;
- cin >> a;
- cout << "Podaj b: " << endl;
- cin >> b;
- cout << "Podaj c: " << endl;
- cin >> c;
- }
- void trojkat::podaj_wys()
- {
- cout << "Podaj wysokosc" << endl;
- cin >> wys;
- }
- void trojkat::wyswietl_boki()
- {
- cout << "a = " << a << endl;
- cout << "b = " << b << endl;
- cout << "c = " << c << endl;
- }
- double trojkat::pole()
- {
- return (a * wys) / 2;
- }
- double trojkat::obwod()
- {
- return a + b + c;
- }
- double trojkat::suma_katow()
- {
- return (ilosc_bokow - 2) * 180;
- }
- int main()
- {
- figura f;
- trojkat t1;
- trojkat t2;
- trojkat t3;
- trojkat t4;
- f.nazwa = "Figura";
- cout << f.nazwa << endl;
- cout << endl;
- t1.nazwa = "Trojkat typu duzy";
- t1.podaj_boki();
- t1.wyswietl_boki();
- t1.podaj_wys();
- cout << "Pole wynosi: " << t1.pole() << endl;
- cout << "Obwod wynosi: " << t1.obwod() << endl;
- cout << "Suma katow wynosi: " << t1.suma_katow() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement