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