Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin>>n;
  9. if(n==1) cout<<"*";
  10. else
  11. {
  12. for(int i=1;i<=n;i++)
  13. if(i==n) cout<<"*";
  14. else cout<<" ";
  15. cout<<endl;
  16. for(int i=2;i<=n-1;i++)
  17. {
  18. for(int j=i;j<=n-1;j++)
  19. cout<<" ";
  20. cout<<"*";
  21. for(int j=1;j<=2*(i-1)-1;j++) cout<<" ";
  22. cout<<"*";
  23. cout<<endl;
  24. }
  25. for(int i=1;i<=2*n;i++)
  26. if(i%2==1) cout<<"*";
  27. else cout<<" ";
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement