fork download
  1. /* Author haleyk10198 */
  2. /* §@ªÌ: haleyk10198 */
  3. #include <bits/stdc++.h>
  4.  
  5. #define MOD 1000000007
  6. #define LINF (1LL<<60)
  7. #define INF 2147483647
  8. #define PI 3.1415926535897932384626433
  9. #define ll long long
  10. #define pii pair<int,int>
  11. #define mp(x,y) make_pair((x),(y))
  12.  
  13. using namespace std;
  14.  
  15. string itos(int x){
  16. stringstream ss;
  17. ss<<x;
  18. return ss.str();
  19. }
  20.  
  21. void f(int now, int dx){
  22. if(now == 1){
  23. cout << string(dx, ' ') + "*" << endl
  24. << string(dx, ' ') + "**" << endl
  25. << string(dx+1, ' ') + "*" << endl;
  26. return;
  27. }
  28. f(now - 1, dx);
  29. cout << string(dx, ' ') + string(2*now, '*') << endl;
  30. f(now - 1, dx + now);
  31. }
  32.  
  33. int n;
  34.  
  35. int main(){
  36. //freopen("input.txt","r",stdin);
  37. //freopen("output.txt","w",stdout);
  38. ios_base::sync_with_stdio(false);
  39. cin >> n;
  40. f(n, 0);
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 3472KB
stdin
3
stdout
*
**
 *
****
  *
  **
   *
******
   *
   **
    *
   ****
     *
     **
      *