Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. class prostokat {
  6. int wciecie;
  7. int wysokosc;
  8. int szerokosc;
  9. char znak;
  10. public:
  11. prostokat(int _wciecie,int _wysokosc,int _szerokosc, char _znak)
  12. : wciecie(_wciecie),wysokosc(_wysokosc),szerokosc(_szerokosc),znak(_znak)
  13. {}
  14.  
  15. friend ostream& operator<<(ostream& out, const prostokat& f)
  16. {
  17. int w = out.width();
  18.  
  19. for (int i = 0; i < f.wysokosc; i++)
  20. {
  21. out << setw(f.wciecie);
  22.  
  23. for (int x = 0; x < f.szerokosc; x++)
  24. {
  25. out << f.znak;
  26. }
  27.  
  28. out << endl;
  29. }
  30.  
  31. setw(w);
  32.  
  33. return out;
  34. }
  35. };
  36.  
  37. class trojkat {
  38. int wysokosc;
  39. char znak;
  40. public:
  41. trojkat(int _wysokosc, char _znak)
  42. : wysokosc(_wysokosc),znak(_znak)
  43. {}
  44.  
  45. friend ostream& operator<<(ostream& out, const trojkat& f)
  46. {
  47. int w = out.width();
  48.  
  49. for (int i = 1; i <= f.wysokosc; i++)
  50. {
  51. out << setw(f.wysokosc - i);
  52.  
  53. for (int x = 0; x < (2 * i) - 1; x++)
  54. {
  55. out << f.znak;
  56. }
  57. out << endl;
  58. }
  59.  
  60. setw(w);
  61.  
  62. return out;
  63. }
  64. };
  65.  
  66. int main()
  67. {
  68. cout << prostokat(50, 20, 50, '%');
  69. cout << trojkat(50, '$');
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement