fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin >> n;
  9.  
  10. int x = 0, y = n-2;
  11. for (int i = 1; i <= n; i++)
  12. {
  13. for (int u = 0; u <= y; u++){
  14. cout << " ";
  15. }
  16. y -= 1;
  17.  
  18. for (int j = 0; j <= x; j++){
  19. cout << '*';
  20. }
  21. x += 2;
  22.  
  23. cout << "\n";
  24.  
  25. }
  26.  
  27. // __________________
  28.  
  29. x = n+2, y = 0;
  30. for (int i = 1; i <= n; i++)
  31. {
  32.  
  33. for (int u = 0; u <= y-1; u++){
  34. cout << " ";
  35. }
  36. y += 1;
  37.  
  38. for (int j = 0; j <= x; j++){
  39. cout << '*';
  40. }
  41. x -= 2;
  42.  
  43. cout << "\n";
  44. }
  45.  
  46. return 0;
  47. }
  48.  
Success #stdin #stdout 0.01s 5320KB
stdin
4
stdout
   *
  ***
 *****
*******
*******
 *****
  ***
   *