Advertisement
Amigoz695

5) a)

Feb 26th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int size() {
  6.     int a;
  7.     cin >> a;
  8.     return a;
  9. }
  10.  
  11. void drawManyChars(char c, int k) {
  12.     while (k > 0) {
  13.         cout << c;
  14.         k--;
  15.     }
  16. }
  17.  
  18. void upperPart(int n) {
  19.     int b = n;
  20.     while (n > 0) {
  21.         drawManyChars(' ', n);
  22.         n--;
  23.         drawManyChars('*', b-n);
  24.         cout << endl;
  25.         b++;
  26.     }
  27. }
  28.  
  29. void lowPart(int n) {
  30.     drawManyChars(' ', n);
  31.     drawManyChars('*', 1);
  32. }
  33.  
  34. void tree() {
  35.     int ab = size();
  36.     upperPart(ab);
  37.     lowPart(ab);
  38. }
  39.  
  40. int main() {
  41.      tree();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement