Advertisement
ZhilinskiyG

Piramid

Mar 6th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4. void line(int n, char sum, bool newLine = true)
  5. {
  6. int i = 0;
  7. while (i < n) {
  8. cout << "*";
  9. i++;
  10. }
  11. cout << endl;
  12. }
  13. void rect(int a, int b)
  14. {
  15. int i = 0;
  16. while (i < b) {
  17. cout << "*";
  18. line(b, false);
  19. i++;
  20. }
  21. cout << endl;
  22. }
  23. void triangle(int a) {
  24. int i = 0;
  25. while (i < a) {
  26. line(i, false);
  27. i++;
  28. }
  29. cout << endl;
  30. }
  31. void piramid(int a) {
  32. int i = 0;
  33. while (i < a) {
  34. line(i + 1, '*', true);
  35. line(i - i - 1, ' ', false);
  36. ++i;
  37. }
  38. }
  39. int main()
  40. {
  41. rect(8, 8);
  42. triangle(8);
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement