Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- class prostokat {
- int wciecie;
- int wysokosc;
- int szerokosc;
- char znak;
- public:
- prostokat(int _wciecie,int _wysokosc,int _szerokosc, char _znak)
- : wciecie(_wciecie),wysokosc(_wysokosc),szerokosc(_szerokosc),znak(_znak)
- {}
- friend ostream& operator<<(ostream& out, const prostokat& f)
- {
- int w = out.width();
- for (int i = 0; i < f.wysokosc; i++)
- {
- out << setw(f.wciecie);
- for (int x = 0; x < f.szerokosc; x++)
- {
- out << f.znak;
- }
- out << endl;
- }
- setw(w);
- return out;
- }
- };
- class trojkat {
- int wysokosc;
- char znak;
- public:
- trojkat(int _wysokosc, char _znak)
- : wysokosc(_wysokosc),znak(_znak)
- {}
- friend ostream& operator<<(ostream& out, const trojkat& f)
- {
- int w = out.width();
- for (int i = 1; i <= f.wysokosc; i++)
- {
- out << setw(f.wysokosc - i);
- for (int x = 0; x < (2 * i) - 1; x++)
- {
- out << f.znak;
- }
- out << endl;
- }
- setw(w);
- return out;
- }
- };
- int main()
- {
- cout << prostokat(50, 20, 50, '%');
- cout << trojkat(50, '$');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement