Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. int n, a, b, midpoint;
  2. std::cin>>n;
  3. midpoint = (n + 1)/2;
  4. for(a = 0; a <= midpoint; a++) {
  5. for(b = 0; b <= (midpoint*2); b++) {
  6. if( (b == (midpoint - a)) || (b == (midpoint + a)) ) {
  7. std::cout<<" * ";
  8. }//end of star printing condition
  9. else {
  10. std::cout<<" ";
  11. }//end of space condition
  12. }//end of col constructor
  13. std::cout<<std::endl;
  14. }//end of row constructor
  15.  
  16.  
  17. for(a = midpoint-1; a >= 0; a--) {
  18. for(b = 0; b <= (midpoint*2); b++) {
  19. if( (b == (midpoint - a)) || (b == (midpoint + a)) ) {
  20. std::cout<<" * ";
  21. }//end of star printing condition
  22. else {
  23. std::cout<<" ";
  24. }//end of space condition
  25. }//end of col constructor
  26. std::cout<<std::endl;
  27. }//end of row constructor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement