fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n;
  7. cin >> n;
  8. int x = (n / 2) + 1;
  9.  
  10. // First part
  11. for (int i = 0; i < x; i++) {
  12. for (int j = 0; j < x - i - 1; j++) {
  13. cout << ".";
  14. }
  15. for (int j = 0; j < 2 * i + 1; j++) {
  16. cout << "*";
  17. }
  18. cout << endl;
  19. }
  20.  
  21. // Second part
  22. for (int i = 0; i <(n - x); i++) {
  23. for (int j = 0; j < i; j++) {
  24. cout << ".";
  25. }
  26. for (int j = 0; j < n - (2 * i); j++) {
  27. cout << "*";
  28. }
  29. cout << endl;
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0s 5324KB
stdin
5
stdout
..*
.***
*****
*****
.***